vuejs/vue

Can't "provide" reactive data property whose type is String or Number

HawtinZeng opened this issue · 4 comments

Version

2.7.14

Reproduction link

stackblitz.com

Steps to reproduce

Click the button in the page.

What is expected?

"testNumber" in the Inner component is added after clicking the button.

What is actually happening?

I have provided "testNumber " in the Outer component, but I can't inject "testNumber " as reactive data in the Inner component.


I found when I provided reactive data whose type is Object, the injected data is reactive in the Inner component.So I will fix this problem by providing Object data consisting of a cluster of data.

After removing element-ui, the error doesn't appear. You should maybe report the bug there.

Thanks for your replay, the error still exists after removing element-ui, stackblitz link, but I can provide "this"(parent instance), then refer "this.testNumber" to get the injected reactive data.

There is still no warning, before or after updating your dependencies.
BTW, it's normal for the number not to be reactive you can find more in docs

I found the explanation in the doc untill just now! Thank you, bro, you are so kind!