Get this in the js file in vue (vue instance)

Get this (vue instance) in the js file in vue
1. Throw the vue instance in main.js and introduce it where you need it.

in main.js

let vueThis= new Vue({
  el: '#app',
  router,
  store,
  data:{
    Bus: new Vue()
  },
  render: h => h(App)
}).$mount('#app');
export default vueThis

In the js to be used

Import Vue from'@/main'
can use Vue.$XXX

2. Pass in the this in the current page in the form of parameter, js file to receive this, (self Baidu, less chance to use, js is generally Public method, pass this every time you use it)
 

Guess you like

Origin blog.csdn.net/wwf1225/article/details/114210832