我想导入
从’@ angular / upgrade / static’导入{UpgradeComponent};
使用ngupgrade在angular2中使用angular1指令,但我收到此错误.
从’@ angular / upgrade / static’导入{UpgradeComponent};
使用ngupgrade在angular2中使用angular1指令,但我收到此错误.
码:
import { Directive,ElementRef,Injector } from '@angular/core'; import { UpgradeComponent } from '@angular/upgrade/static'; @Directive({ selector: 'help' }) export class HelpComponentA1Directive extends UpgradeComponent { constructor(elementRef: ElementRef,injector: Injector) { super('help',elementRef,injector); } }
解决方法
export不是一个javascript关键字,当它应该加载已编译的.js文件时,你的浏览器会以某种方式加载.ts文件.
根据您用于捆绑模块的方法,解决此问题的解决方案可能是任何问题.但是你有一个告诉浏览器的指令,当它看到@ angular / upgrade / static时,它应该加载node_modules/@angular/upgrade/static.ts.它应该加载其中一个
> node_modules/@angular/upgrade/static.js,或
> node_modules/@angular/upgrade/bundles/static.umd.js
您可能遇到的另一个潜在问题(我已经多次遇到过这种问题)是您已经在@ angular / upgrade / static某处注释了一个import语句.