新建js文件
var fun = function (info) {
console.log('hello -> '+info)
}
export default fun
main.js导包并挂载
import log from './common/common.js'
Vue.prototype.$log = log
使用
this.$log('android created')
var fun = function (info) {
console.log('hello -> '+info)
}
export default fun
import log from './common/common.js'
Vue.prototype.$log = log
this.$log('android created')
本文标题:Vue 全局方法封装,以log为例
本文链接:https://www.haomeiwen.com/subject/gzfxqktx.html
网友评论