vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

Consider pre-initializing the property with the "data" option for more reliable reactivity and better performance #504

Open zwl1619 opened 8 years ago

zwl1619 commented 8 years ago

this is my code, https://jsfiddle.net/0od4hwmh/2/ it can be running when pick it out, but when put it in my project of laravel 5.3, there is an error:

[Vue warn]: You are setting a non-existent path "chosenFruite" on a vm instance. Consider pre-initializing the property with the "data" option for more reliable reactivity and better performance.

What is the probable problem?

LinusBorg commented 8 years ago

chosenfruite was outside of the data property. It should be initialized in the data, like the items array.

Example: https://jsfiddle.net/0od4hwmh/3/

zwl1619 commented 8 years ago

@LinusBorg
it doesn't work.

LinusBorg commented 8 years ago

Well, my provided example does work: it sets chosenfruite correctly, and no warning is displayed.

What does not work for you?