vue-cli創(chuàng)建的項(xiàng)目utils/index.js代碼如下exports.install = function (Vue, options) {
Vue.prototype.test= function () {
JSON.stringify({})
console.log('執(zhí)行成功')
}
};main.js代碼如下import commonFun from './utils/index'Vue.use(commonFun)瀏覽器報(bào)錯(cuò) exports is not defined控制臺(tái)報(bào)錯(cuò) export 'default' (imported as 'commonFun') was not found in './utils/index'刪除 JSON.stringify ,無異常!問題已經(jīng)解決,根據(jù)@gaoryrt回答那樣,改寫如下,it work!export default {
install(Vue, options) {
Vue.prototype.Utils = {
funA(o) {
...
},
funB(o) {
...
}
}
}
}
vue 中插件中使用 JSON.stringify 報(bào)錯(cuò)
隔江千里
2018-07-09 16:19:18