Element: Property or method toJSON is not defined on the instance but referenced during render

Created on 27 Feb 2017  ·  13Comments  ·  Source: ElemeFE/element

image
gist with example html: https://gist.github.com/cili93/e75433714ecad7390eb1b7476532e09d

This error was showing up for el-select, then I moved to el-dropdown and it stopped showing up. Now it's showing up again, for el-dropdown this time.
Could you PLEASE tell me why in the world is it showing up and where is the problem ?

It shows whenever I click on dropdown or dropdown item

repro

Most helpful comment

when i click the button open dialog ,show the same problem Property or method "toJSON" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
i dont know why

All 13 comments

Please search your project for toJSON

Oh I did, 0 matches my friend
All of them are in node modules, nothing in project itself

I couldn't reproduce your problem with the gist you provided. Could you write an online demo using jsfiddle?

I can't believe there's isn't like a hundred people with this problem, me and two more colleagues are having the same issue
I'll try to create a demo today, thank you

Now it's working like a glove, I guess somebody changed something and fixed it without even knowing
We had a lot of problems with this earlier but some stars matched and now it's working as it should I guess
I'll close the issue for now, if it appears again I'll try to make a fiddle and reproduce it somehow

Thanks for wanting to help guys, I appreciate it 👍 👨

No problem. Tell us if this happens again.

I am also seeing this error on both el-tabs and el-collapse. It shows up pretty inconsistently and I haven't been able to pinpoint what conditions cause it to occur. @cili93, have you seen this showing up anymore?

when i click the button open dialog ,show the same problem Property or method "toJSON" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
i dont know why

Maybe because of the vue-dev-tool plugin for chrome... for example
option.vue beforeDestroy: function beforeDestroy() { this.dispatch('ElSelect', 'onOptionDestroy', this); }
such this payload will be recorded by vue dev tool.But this has no toJSON method.

@earlymeme is right. I disabled vue-devtools in chrome and the warning went away. Re-enabling vue devtools, and restarting chrome dev tools brings the warning back.

Another way to repro:
1) navigate to the page where the warning occurs
2) if chrome dev tools is already open, close it and refresh the page (this ensures vue devtools is unloaded)
3) open chrome dev tools (do NOT go to the vue devtools tab)
4) interact with the elementui control that causes the warnings
5) note that there are no warnings
6) go to the vue devtools tab in chrome dev tools
7) interact with the elementui control that causes the warnings
8) not that the warnings appear in the console now

Clearly vue devtools is triggering these warnings, but is the bug that vue devtools is doing something it shouldn't or is the fix for elementui to provide some additional property or method to make it more easily debuggable by vue devtools?

[edit] Looks like there is a recent issue about this on the vue devtools repo.

[edit edit] I have created an issue about how this "toJSON" warning can actually end up blocking the main execution thread.

In my project, I opened the console, by this

window.vConsole = new VConsole();

but when I commented it. It works, the Vue warn was disappeared.

In my project, I opened the console, by this

window.vConsole = new VConsole();

but when I commented it. It works, the Vue warn was disappeared.

thank you very much that solve my same problem


If the model director was set this the warning will be shown.

Was this page helpful?
0 / 5 - 0 ratings