"export 'default' (imported as '...') was not found in ''..."

开发中遇到的一个简单问题 却花了我很长时间

//在一个js文件中导出fetch请求方法
import fetch from 'utils/fetch';

export function getCompanyList() {
  return fetch({
    url: '/wx/company/list',
    method: 'get'
  })
}
//在vue的script代码块中导出
import getCompanyList from 'api/recruitManage/index';

//调用请求
  methods: {
    getList() {
      getCompanyList().then(res => {
        if (res.errno == 0) {
          this.companys = res.data
        }
      });
    }
  }

编译时警告:

 warning  in ./src/views/oa/recruitManage/index.vue

23:6-20 "export 'default' (imported as 'getCompanyList') was not found in 'api/recruitManage/index'

一开始没看到警告 请求时报错 

[Vue warn]: Error in v-on handler: "TypeError: __webpack_require__.i(...) is not a function"

TypeError: __webpack_require__.i(...) is not a function

试了很久没有解决 最后发现时import语法问题

在import后面加上大括号解决
import {getCompanyList} from 'api/recruitManage/index';

import,export语法规范详解:http://es6.ruanyifeng.com/#docs/module#export

 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页