js文件引入其他js文件

function loadJavaScript(url, success) {
    let domScript = document.createElement('script');
    domScript.src = url;
    success = success || function () {};
    domScript.onload = domScript.onreadystatechange = function () {
        if (!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState) {
            success();
            this.onload = this.onreadystatechange = null;
            this.parentNode.removeChild(this);
        }
    }
    document.getElementsByTagName('head')[0].appendChild(domScript);
}

loadJavaScript('../../static/js/plugin/vue.js', function () {
    // do it!
})

版权声明:本文为qq_39993715原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。