File tree 1 file changed +15
-2
lines changed
packages/runtime-core/src
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -299,12 +299,16 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
299
299
// to infinite warning loop
300
300
key . indexOf ( '__v' ) !== 0 )
301
301
) {
302
- if ( data !== EMPTY_OBJ && key [ 0 ] === '$' && hasOwn ( data , key ) ) {
302
+ if (
303
+ data !== EMPTY_OBJ &&
304
+ ( key [ 0 ] === '$' || key [ 0 ] === '_' ) &&
305
+ hasOwn ( data , key )
306
+ ) {
303
307
warn (
304
308
`Property ${ JSON . stringify (
305
309
key
306
310
) } must be accessed via $data because it starts with a reserved ` +
307
- `character and is not proxied on the render context.`
311
+ `character ("$" or "_") and is not proxied on the render context.`
308
312
)
309
313
} else {
310
314
warn (
@@ -474,6 +478,15 @@ export function exposeSetupStateOnRenderContext(
474
478
) {
475
479
const { ctx, setupState } = instance
476
480
Object . keys ( toRaw ( setupState ) ) . forEach ( key => {
481
+ if ( key [ 0 ] === '$' || key [ 0 ] === '_' ) {
482
+ warn (
483
+ `setup() return property ${ JSON . stringify (
484
+ key
485
+ ) } should not start with "$" or "_" ` +
486
+ `which are reserved prefixes for Vue internals.`
487
+ )
488
+ return
489
+ }
477
490
Object . defineProperty ( ctx , key , {
478
491
enumerable : true ,
479
492
configurable : true ,
You can’t perform that action at this time.
0 commit comments