angular - Safari ReferenceError:找不到变量:Tmpo(= 纯 js 类)
问题描述
我编写了一个小型 Angular 应用程序,它在我的 assets/js 文件夹中使用了一个简单的 js 类。一切都在我的本地环境中完美运行(ng-serve)。当我构建和部署我的应用程序(ng build --prod)时,我得到一个ReferenceError: Can't find variable: Tmpo。但是,仅在 Safari 中...
此处提供代码:https ://github.com/flukso/flukso.github.io 此处提供站点:https ://flukso.github.io
我的 js 类 (tmpo.js)
$.ajaxSetup({
timeout: 10 * 60 * 1000, // msecs
cache: false
})
class Tmpo {
constructor(uid, token, debug = false) {
...
}
...
}
在angular.json
:
...
"scripts": [
"src/assets/js/tmpo.js"
]
...
在我的组件中:
import ...
declare var Tmpo: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
export() {
const tmpo = new Tmpo(null, this.token.value, false);
...
}
}
解决方案
试试这个,前几天遇到了类似的问题:
ng build --prod --aot --service-worker --base-href ./
推荐阅读
- angular - Angular ag-grid:从@input 字段设置 gridOptions
- node.js - NodeJs,Mocha:从父文件夹导入问题
- python - 无法导入 cairocffi 库
- bluetooth-lowenergy - LabView 中的 BLE113 数据读取 - 较低的采样频率
- python - 为 Python 3.x 编译 zbar
- laravel - Laravel - 测试具有数据依赖关系的 API
- hugo - 安装两个不同版本的 Hugo (ubuntu)
- python - Pandas:Groupby并聚合json,float类型的多个列
- c# - 将数据从 Scrapy 推送到 .Net 应用程序的最佳方法
- jupyter-notebook - Watson Studio 支持 jupyter 数据表吗?