默认导出未在导入模块中声明

default export is not declared in imported module

我在 IntelliJ IDEA 中使用 ES6。下面是一段代码。

import controller from './tpmInfo.ctrl.js'
import template from './tpmInfo.tpl.html' //default export is not declared in imported module

export default angular.module('tmpApp', [])
    .component('tpmInfo', {
        template: template,
        controller: controller,
        bindings: {
            ags: '='
        }
    })
.name;

template html 是正常的 html,但 IntelliJ IDEA 抛出警告 "default export is not declared in imported module"。有没有办法让这个警告消失?谢谢

试试这个:

import * as tpl from './tpmInfo.tpl.html'

然后像这样使用它:

template: tpl.template,

让我知道这是否适合你。

对于 Angular2-Meteor 项目,我必须像 Wassim 所说的那样做,并进行一些小改动:

import * as tpl from './tpmInfo.tpl.html'
然后在 Component
template: tpl.default

import * as templatefrom './tpmInfo.tpl.html';  
template = template.default;

  @Component({
   //smth,      
    template
  })

这是一个字符串,由angular2-compilers模块

返回