[英]material design lite append icon
我在附加使用材質圖標的a時遇到問題,似乎沒有加載css / js,而是顯示了單詞check
-這部分來自stepper.js
var i = document.createElement('i');
i.style.className = 'material-icons';
var text = document.createTextNode('check');
i.appendChild(text);
elements.appendChild(i);
我想知道如何重新加載js文件或重新加載材料字體部分?
我的標頭-我如何加載樣式表和js
<script type="text/javascript">
var uid = '{$smarty.session.ipet_user}';
{literal}
function stylesheet(url) {
var s = document.createElement('link');
s.rel = 'stylesheet';
s.async = false;
s.href = url;
var x = document.getElementsByTagName('head')[0];
x.appendChild(s);
}
function script(url) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = url;
//s.defer = true;
var x = document.getElementsByTagName('head')[0];
x.appendChild(s);
}
(function () {
stylesheet('https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css');
stylesheet('https://fonts.googleapis.com/css?family=Roboto');
stylesheet('https://fonts.googleapis.com/icon?family=Material+Icons');
stylesheet('./templates/main/user-theme/tpl-files/material.act.css');
stylesheet('plugins/dropzone/dropzone.css');
stylesheet('plugins/stepper/stepper.min.css');
stylesheet('./templates/main/user-theme/tpl-files/style.css');
stylesheet('./templates/main/style/newprofile.css');
stylesheet('plugins/getmdlselect/getmdl-select.min.css');
script('https://code.getmdl.io/1.3.0/material.min.js');
script('https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js');
script('https://apis.google.com/js/api:client.js');
script('https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyBk99v0F4qkmvxifqOD48YktK-QO-3kopI');
script('./templates/main/user-theme/javascript/google.js');
script('plugins/getmdlselect/getmdl-select.min.js');
script('./templates/main/user-theme/javascript/facebook.js');
script('./templates/main/user-theme/javascript/newprofile.js');
script('./templates/main/javascript/zipcode.js');
script('plugins/stepper/v2/stepper.js');
})();
</script>
您必須通過.className
而不是.style.className
定義元素的類
i.className = 'material-icons';
var elements = document.body; var i = document.createElement('i'); i.className = 'material-icons'; var text = document.createTextNode('check'); i.appendChild(text); elements.appendChild(i);
<head> </head> <body> <script> function stylesheet(url) { var s = document.createElement('link'); s.rel = 'stylesheet'; s.async = false; s.href = url; var x = document.getElementsByTagName('head')[0]; x.appendChild(s); } function script(url) { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = url; //s.defer = true; var x = document.getElementsByTagName('head')[0]; x.appendChild(s); } (function () { stylesheet('https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css'); stylesheet('https://fonts.googleapis.com/css?family=Roboto'); stylesheet('https://fonts.googleapis.com/icon?family=Material+Icons'); stylesheet('./templates/main/user-theme/tpl-files/material.act.css'); stylesheet('plugins/dropzone/dropzone.css'); stylesheet('plugins/stepper/stepper.min.css'); stylesheet('./templates/main/user-theme/tpl-files/style.css'); stylesheet('./templates/main/style/newprofile.css'); stylesheet('plugins/getmdlselect/getmdl-select.min.css'); script('https://code.getmdl.io/1.3.0/material.min.js'); script('https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'); script('https://apis.google.com/js/api:client.js'); script('https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyBk99v0F4qkmvxifqOD48YktK-QO-3kopI'); script('./templates/main/user-theme/javascript/google.js'); script('plugins/getmdlselect/getmdl-select.min.js'); script('./templates/main/user-theme/javascript/facebook.js'); script('./templates/main/user-theme/javascript/newprofile.js'); script('./templates/main/javascript/zipcode.js'); script('plugins/stepper/v2/stepper.js'); })();</script> </body>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.