Properties that start with "_" will be proxied on the component instance when using options data.
Version
3.2.32
Reproduction link
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."
Don't use this
in the template and follow the warning of using $data
for properties that start with _
.
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