错误消息:
TypeError: "x" is (not) "y"
Examples:
TypeError: "x" is undefined
TypeError: "x" is null
TypeError: "undefined" is not an object
TypeError: "x" is not an object or null
TypeError: "x" is not a symbol
出现了与期望不符的类型。
这个错误常常由 undefined 或 null 值引起。
此外,某些方法,例如 Object.create() 或 Symbol.keyFor(), 要求必须提供特定类型的参数。
解决方法:
要解决空指针以及 undefined 或 null 值的问题, 你可以使用 typeof 操作符, 例如:
if (typeof foo !== 'undefined') {
// Now we know that foo is defined, we are good to go.
}
相关阅读 >>
更多相关阅读请进入《TypeError》频道 >>

Vue.js 设计与实现 基于Vue.js 3 深入解析Vue.js 设计细节
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者