Subscribe on changes!

Error with custom app.config.globalProperties._

avatar
Nov 3rd 2020

Version

3.0.2

Reproduction link

https://codesandbox.io/s/compassionate-leakey-1wwix?file=/src/main.js

Steps to reproduce

When add lodash app.config.globalProperties._ = _;, there's a error. Does vue3 disable custom globalProperties._?

What is expected?

No error

What is actually happening?

image

Uncaught (in promise) TypeError: Cannot read property '__v_raw' of undefined

avatar
Nov 3rd 2020

"_" is a reserved name,

https://github.com/vuejs/vue-next/blob/a1eb1e59ecb5bf43d62950f68fec5115ba0a1d24/packages/runtime-core/src/componentPublicInstance.ts#L228-L231

But we don'T check for this when a globalProperty is assigned, as globalProperties is a simple object.

to check for this reserved name, we would have to use a special object with a getter/setter or a proxy during development.

avatar
Nov 3rd 2020

Workaround: use a different property name.