vue-cli
Project created
utils/index.js
the code is as follows
exports.install = function (Vue, options) {
Vue.prototype.test= function () {
JSON.stringify({})
console.log("")
}
};
main.js
the code is as follows
import commonFun from "./utils/index"
Vue.use(commonFun)
browser exports is not defined
console export "default" (imported as" commonFun") was not found in. / utils/index"
Delete JSON.stringify
, no exception!
problem has been solved. According to the answer @ gaoryrt
, rewrite as follows: it work!
export default {
install(Vue, options) {
Vue.prototype.Utils = {
funA(o) {
...
},
funB(o) {
...
}
}
}
}