它可能是錯誤必須聲明使用CSS字體facedeclaraciones在例如優化設計和Unicode支持
使用的字體複製所有的DOM到image.js爲什麼我發現作爲一個鏈接外部道歉爲此 https://jsfiddle.net/sLc2kcwy/
<style type="text/css">
body{background: url('assets/img/fondo.jpg') no-repeat;overflow: auto;color:#fff;padding: 0px;margin: 0px;}
body {
background: #000;
}
.label {
display: inline-block;
width: 200px;
color: white;
}
#root {
display: inline-block;
width: 200px;
height: 300px;
text-align: center;
color: #ccc;
font-size: 20pt;
vertical-align: top;
}
#captured {
display: inline-block;
vertical-align: top;
}
.square {
display: block;
margin-top: 50px;
margin-left: 50px;
margin-bottom: 50px;
width: 100px;
height: 100px;
background: blue;
transform: rotate(45deg);
}
/* fallback */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url(https://fonts.gstatic.com/s/materialicons/v17/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}
</style>
</head>
<body>
<div id="root">
<i class="material-icons">add</i>
</div>
<script type="text/javascript" src="assets/js/dom-to-image.js"></script>
<script type="text/javascript">
var node = document.getElementById('root');
domtoimage.toPng(node)
.then(function (dataUrl) {
var img = new Image();
img.src = dataUrl;
document.body.appendChild(img);
})
.catch(function (error) {
console.error('oops, something went wrong!', error);
});
</script>
哦,究竟是什麼。所以唯一的問題是從外部加載材質圖標.css?哇。非常感謝,我不會猜到這一點。 – MortenMoulder
我很樂意提供幫助 –