在需要的界面中:如何
实例说明:
中<script>
function zhuruJs(url) {
let temp = document.createElement( 'script ');
temp.setAttribute( 'type', 'text/javascript" );temp.src = urL;
document.head . appendChild(temp);
zhuruJs(location.origin+ ' /assets/js/ceshi.js ')
</script>
注意:zhuruJs 这个函数的中路径是 你自己写的js 中绝对路径
本文介绍了如何在网页中使用JavaScript的zhuruJs函数实现动态加载外部脚本,通过createElement和setAttribute方法设置script元素属性,实现在需要的界面中加载自定义js文件。
1032

被折叠的 条评论
为什么被折叠?



