动态追加js

判断是否已引用js,如果没有会引发异常,在异常时添加引用

 try {
        if (layui) {}
    }
    catch (ex) {
        var s = document.createElement('script');
        s.src = '/Content/Layui/layui.js';
        document.head.appendChild(s);
    }
原文地址:https://www.cnblogs.com/xiaonangua/p/9887867.html