vue-cli创建的项目utils/index.js代码如下exports.install = function (Vue, options) { Vue.prototype.test= function () { JSON.stringify({}) console.log('执行成功') }};main.js代码如下import commonFun from './utils/index'Vue.use(commonFun)浏览器报错 exports is not defined控制台报错 export 'default' (imported as 'commonFun') was not found in './utils/index'删除 JSON.stringify ,无异常!问题已经解决,根据@gaoryrt回答那样,改写如下,it work!export default { install(Vue, options) { Vue.prototype.Utils = { funA(o) { ... }, funB(o) { ... } } }}
添加回答
举报
0/150
提交
取消