1、建立一个中转站
2、然后在两个页面都引入它,注意引入路径。
import Utils from './testutils.js'
3、调用方的写法
Utils.$emit('demo', 'msg')
4、被调用方的写法
mounted() {
var that = this
Utils.$on('demo', function(msg) {
that.importFile()
})
},
参考:API-Vue.js
1、建立一个中转站
2、然后在两个页面都引入它,注意引入路径。
import Utils from './testutils.js'
3、调用方的写法
Utils.$emit('demo', 'msg')
4、被调用方的写法
mounted() {
var that = this
Utils.$on('demo', function(msg) {
that.importFile()
})
},
参考:API-Vue.js