在Angular 1.x应用程序上工作,使用ES6,Angular Linter和Babel进行转换.我收到此错误:"TypeError:无法在控制台中调用类作为函数",虽然html加载得很好.
TypeError: Cannot call a class as a function
at _classCallCheck (bundle.js:97664)
at Object.loginNotifyService (bundle.js:97670)
at Object.invoke (bundle.js:23052)
at Object.enforcedReturnValue [as $get] (bundle.js:22885)
at Object.invoke (bundle.js:23052)
at bundle.js:22844
at getService (bundle.js:22993)
at injectionArgs (bundle.js:23018)
at Object.invoke (bundle.js:23044)
at $controllerInit (bundle.js:29012) "<div ui-view="" class="ng-scope">"
Run Code Online (Sandbox Code Playgroud)
我能说的最好,语法是正确的.我最好的猜测是Babel转向ES5,特别是:
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
Run Code Online (Sandbox Code Playgroud)
这是源JS:
'use strict';
class loginNotifyService {
constructor (notify) {
this.loginNotifyService = notify;
}
info …Run Code Online (Sandbox Code Playgroud)