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

2020-05-27 11:35:50

其实这并不是一个错误,这是一个提醒,网上又很多也遇到这样问题的,但并不是和我的一样。

有人遇到这样的问题: 参考地址  Property or method "toJSON" is not defined on the instance but referenced during render. Make sure t

    

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


一直有这个报错。说是属性或方法“tojson”不是在实例上定义的,而是在呈现过程中引用的。确保此属性为通过初始化属性,确保此属性在数据选项中或对于基于类的组件是活动的


最后发现我用了termid这个字段。定义的时候termid:'  ',但是赋值的时候termid=data.id ;但是这个dataid是个数字。最后接口需要字符类型的我又通过termid.toString()转为了字符。


所以初始化定义的数据类型和赋值的数据类型格式不一样时,就会出现这种错误了。


还有种错误我本来定义的是数组。但是最后传给后台的时候必须传字符串。我就把这个数组toSting了。这违背了我开始定义的数组。而赋值成了字符串。这个时候也会报这种错误。


也有人遇到这样的问题 参考地址 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)就能解决这个问题


为什么会出现这个问题?后续研究研究


通过第二种,我发现了我的问题。我是先 

oElm = document.getElementById(id)

然后

console.info('eELM',oElm)

出现了错误。

这样大家应该心里明白了吧。





  • 2020-05-07 13:43:02

    css模拟开关按钮

    之前我们为大家分享过很多款各式各样的CSS3开关切换按钮,很多还是非常富有创意的,比如这里的多组超具创意的CSS3开关切换按钮和纯CSS3灯光开关动画。今天我们要带来另外一款外观很漂亮的纯CSS3开关切换按钮动画,它模拟了电灯的开关,并且在开和关之间切换时按钮的背景会有不同的变化,看起来非常不错。

  • 2020-05-07 18:40:35

    CSS让页面平滑滚动

    凡是需要滚动的地方都加一句scroll-behavior:smooth就好了!

  • 2020-05-12 10:17:07

    createElementNS和createElement区别

    指定与元素相关联的命名空间URI的字符串。创建的元素的namespaceURI属性使用namespaceURI的值进行初始化。 参见有效的命名空间URL。

  • 2020-05-13 09:37:50

    transform-origin(变形原点) 怎么用

    transform-origin是变形原点,也就是该元素围绕着那个点变形或旋转,该属性只有在设置了transform属性的时候起作用

  • 2020-05-13 09:56:35

    Could not find method google() for arguments [] on repository container.

    1、打开项目根目录下android/gradle/wrapper/gradle-wrapper.properties 将distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip中的2.14.1改成4.1 ———————————————— 版权声明:本文为CSDN博主「peachesTao」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/taoerchun/article/details/93870941

  • 2020-05-13 10:05:23

    inline svg想写介绍以及使用

    inline svg是目前前端图标解决方案的最优解(当然不仅限于图标),而且使用方式也及其简单,只要将svg图标代码当成普通的html元素来使用即可