Subscribe on changes!

Properties that start with "_" will be proxied on the component instance when using options data.

avatar
Apr 14th 2022

Version

3.2.32

Reproduction link

sfc.vuejs.org/

Steps to reproduce

You can see that the property which start with " _ " can be accessed by "this._property". And the property start with "$" throw a warning as expected.

What is expected?

Accessing "_msg" by "this._msg" should throw a warning.

What is actually happening?

Accessing "_msg" by "this._msg" does not throw a warning.


We can see the docs says that "Properties that start with _ or $ will not be proxied on the component instance because they may conflict with Vue's internal properties and API methods. You will have to access them as this.$data._property."

https://vuejs.org/api/options-state.html#data.

avatar
Apr 14th 2022
avatar
Apr 14th 2022

Don't use this in the template and follow the warning of using $data for properties that start with _.

Thank you very much, I know that I should access these properties via $data. But the warning was only triggered by this.$msg. And this._msg will not trigger the warning. sfc playground