1.main.js导出vue实例:
1 var vue = new Vue({ 2 el: '#app', 3 router, 4 components: { App }, 5 template: '<App/>' 6 }) 7 export default vue
2.在需要使用的js中引入
1 import context from '../main.js' 2 context.$router.push('/login')