Tag Archives: Property or method “toJSON” is not defined on the instance but referenced during render

[Solved] Vue error: Property or method “toJSON” is not defined on the instance but referenced during render.

There is a little pit. Note that you cannot use console.log on root instantiation. If you open vconsole, an error will be reported! ! !
      1 Open vconsole and report toJSON is defiend. The positioning problem is in the console.log() and it will not report an error.
      2 If you need to output this thing, please find a place to define it toJSON(){} Although there is no error, I don’t know if there is any problem.
      3 Do not open vconsole without this bug
      4 Comment out when not needed
The reason for the problem is explained on the official website as Vue does not allow dynamic addition of root-level responsive attributes, so you must initialize the Vue instance by pre-declaring all root-level responsive data attributes, even if the value is empty: