我已经在Angular.Cli中提到了我的JS文件路径,它仅在Angular App启动时加载一次,当我们回到组件中时,它没有加载,然后它就没有加载了,请给我一些建议。
感谢您提前的帮助。:(
此IMAY为您提供帮助。
请尝试在index.html上提及它。或在组件上动态加载脚本。
function loadJS(file) {
// DOM: Create the script element
var jsElm = document.createElement("script");
// set the type attribute
jsElm.type = "application/javascript";
// make the script element load file
jsElm.src = file;
// finally insert the element to the body element in order to load the script
document.body.appendChild(jsElm);
}