How do I load a script dynamically via Backbone?
This question already has an answer here:
Manually appending it:
$('head').append('<script type="text/javascript" src="https://domain.com" id="hello" name="abc"></script>')
Using $.getScript
:
$.getScript('https://domain.com').done(function () {
// loaded!
});
RequireJS:
require.config({
paths: {
"myscript": "https://domain.com"
}
});
require(['myscript'], function () {
// loaded!
});
上一篇: 如何链接到JavaScript文件中的JavaScript文件?
下一篇: 如何通过Backbone动态加载脚本?