"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

  • 13
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值