1. 程式人生 > >Vue錯誤——Property or method "toJSON" is not defined on the instance but referenced during render.

Vue錯誤——Property or method "toJSON" is not defined on the instance but referenced during render.

我的vue在註冊過程中報了這個錯誤:

Property or method "toJSON" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

而且影響了router的傳值。

很奇怪的是引起這個問題的原因在於,在於在生命週期的created方法中報錯:

  created() {
    console.log('created');
    console.log(this);
    // console.log('params:' + JSON.stringify(this.$route.params));
  },

一旦去掉console.log(this)就能解決這個問題

為什麼會出現這個問題?後續研究研究