mirror of https://github.com/vuejs/core.git
Merge d516036ee2
into 56be3dd4db
This commit is contained in:
commit
3be608b535
|
@ -526,6 +526,11 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
||||||
`but is not defined on instance.`,
|
`but is not defined on instance.`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else if (__DEV__ && !__TEST__ && !isReservedPrefix(key[0])) {
|
||||||
|
warn(
|
||||||
|
`Property ${JSON.stringify(key)} was accessed during render ` +
|
||||||
|
`but is not defined on instance.`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -311,4 +311,27 @@ describe('compiler + runtime integration', () => {
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(root.innerHTML).toBe('<div>60000000100000111</div>')
|
expect(root.innerHTML).toBe('<div>60000000100000111</div>')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Warning when use undeclared variable in template', () => {
|
||||||
|
const app = createApp({
|
||||||
|
template: `
|
||||||
|
<div @click="handler">handler</div>
|
||||||
|
<div>dddd{{dddd}}</div>
|
||||||
|
<div>no warn: {{message}}</div>
|
||||||
|
`,
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
message: 'hello',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const root = document.createElement('div')
|
||||||
|
app.mount(root)
|
||||||
|
expect(
|
||||||
|
`[Vue warn]: Property "handler" was accessed during render but is not defined on instance.`,
|
||||||
|
).toHaveBeenWarned()
|
||||||
|
expect(
|
||||||
|
`[Vue warn]: Property "dddd" was accessed during render but is not defined on instance.`,
|
||||||
|
).toHaveBeenWarned()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue