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

时间:2016-07-21 16:15:47

标签: angularjs intellij-idea ecmascript-6 phpstorm webstorm

我在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会抛出警告"默认导出未在导入的模块中声明"。有没有办法让这个警告消失?感谢。

2 个答案:

答案 0 :(得分:5)

试试这个:

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

然后像这样使用它:

template: tpl.template,

请告诉我这是否适合您。

答案 1 :(得分:1)

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

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

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

  @Component({
   //smth,      
    template
  })

这是一个由angular2-compilers模块

返回的字符串
相关问题