2 回答
TA贡献1802条经验 获得超5个赞
我遇到了类似的问题并以这种方式解决了它。看看它可能对你有帮助。我在 .ts 文件中以这种方式使用了 DragonSpeech 检测 cdn 并且工作正常。
initiateDragonSpeechToText() {
const fileref = document.createElement('script');
fileref.setAttribute('type', 'text/javascript');
fileref.setAttribute('src',
'https://speechanywhere.nuancehdp.com/3.0/scripts/Nuance.SpeechAnywhere.js?_r=' +
(Math.random() * Math.pow(10, 18)).toString(32));
document.getElementsByTagName('head')[0].appendChild(fileref);
const inlineFunc = document.createElement('script');
inlineFunc.setAttribute('type', 'text/javascript');
const userID = this.UserDetails ? this.UserDetails.UserName : '';
inlineFunc.appendChild(document.createTextNode('function NUSA_configure() {NUSA_userId = "' + userID + '";NUSA_applicationName = "Artisan";NUSA_enableAll = false;}'));
document.getElementsByTagName('head')[0].appendChild(inlineFunc);
}
TA贡献1848条经验 获得超10个赞
你为什么不像这样在 angular.json 中导入外部库?
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/testssss",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [] // add to script section here
},
添加回答
举报