Uncaught ReferenceError: vm is not defined vue.js 2.0


Uncaught ReferenceError: vm is not defined vue.js 2.0

回答1

As mentioned by @Fiete the vm variable wont be available by default.

You need to define vm globally to access it from the console.

Something like this should work

var vm = new Vue({
  el: '#app',
  data: {
    a: 1
  },
  router,
  template: '<App/>',
  components: {
    App
  }
});

global.vm = vm; //Define you app variable globally

Now you can use vm.$data.PROPERTY or vm.PROPERTY.

 

回答2

The vm variable does not exists by default. And vuejs does not set that variable. If you want to debug your vuejs application I recommend the vuejs Chrome extension.

By opening the extension on your page you can select the component you want to debug. After that you can access the selected component by using the $vm0 variable.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM