简体   繁体   English

Safari ReferenceError:无法找到变量:Tmpo(= plain js class)

[英]Safari ReferenceError: Can't find variable: Tmpo (= plain js class)

I wrote a small angular application that makes use of a simple js class in my assets/js folder. 我写了一个小角度应用程序,在我的assets / js文件夹中使用了一个简单的js类。 Everything works perfectly in my local environment (ng-serve). 一切都在我的本地环境(ng-serve)中完美运行。 When I build and deploy my app (ng build --prod) I get a ReferenceError: Can't find variable: Tmpo . 当我构建和部署我的应用程序(ng build --prod)时,我得到一个ReferenceError:无法找到变量:Tmpo But, only in Safari... 但是,只有在Safari ...

code available here: https://github.com/flukso/flukso.github.io site available here: https://flukso.github.io 代码可在此处获取: https//github.com/flukso/flukso.github.io网站: https//flukso.github.io

My js class (tmpo.js) 我的js课程(tmpo.js)

$.ajaxSetup({
  timeout: 10 * 60 * 1000, // msecs
  cache: false
})

class Tmpo {
  constructor(uid, token, debug = false) {
     ...
  }
  ...
}

in angular.json : angular.json

...
"scripts": [
              "src/assets/js/tmpo.js"
            ]
...

in my component: 在我的组件中:

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 ./

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM