我正在使用html和angularjs。我有index.html,我使用了很多(可能是b 13)脚本和链接标签。我想让代码干净。所以我想从中导入所有脚本和链接标签所以我基本上想做的就是
<head>
<script src="javascripts/jquery2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.4.2/angular-ui-router.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="css/fullcalendar.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css">
<link rel="stylesheet" href="css/mainpage.css">
</head>
&#13;
应该成为
<head>
//add all the tags from the file include.html or include.txt something
</head>
&#13;
我搜索了很多,并没有得到任何有效的解决方案。请帮助。谢谢你
答案 0 :(得分:0)
将您的链接存储在JSON格式文件中 ,阅读您的JSON文件,运行for循环并调用以下行
var importedScript = document.createElement('script');
importedScript .src = '/path/to/imported/script';
document.head.appendChild(imported);