Vue js引用警告 "export 'default' (imported as 'Api') was not found in './api'

18,787 阅读1分钟

问题截图:

image.png

问题原因:ES6 编译器识别问题。

方法1:修改引用js的地方

import Api from './api' 改成import * as Api from './api'

api.js中写法

export function getTestAPI() {
    xxx
}

方法2:修改js文件中的function

改成

exports.getTestAPI = function () {
 xxxx
}

方法3:修改js文件export方式

 function getTestAPI() {xxx}
 export default{
    getTestAPI
}