如何以角度動(dòng)態(tài)加載外部腳本?我有一個(gè)模塊,它將外部庫與附加邏輯一起組件化,而不添加<script>標(biāo)記直接插入index.html:import 'http://external.com/path/file.js'//import '../js/file.js'@Component({
selector: 'my-app',
template: `
<script src="http://iknow.com/this/does/not/work/either/file.js"></script>
<div>Template</div>`})export class MyAppComponent {...}我注意到importby ES6規(guī)范是靜態(tài)的,在類型轉(zhuǎn)換過程中解析,而不是在運(yùn)行時(shí)。無論如何,為了使其可配置,文件js將從CDN或本地文件夾加載嗎?如何告訴角2動(dòng)態(tài)加載腳本?
如何以角度動(dòng)態(tài)加載外部腳本?
Qyouu
2019-07-05 13:13:22