解决报错:runtime-core.esm-bundler.js:400 Uncaught TypeError: Cannot read properties of undefined

本文详细介绍了Vue3中createApp函数的使用,包括组件注册、插件安装、配置对象、指令、混入、挂载与卸载功能,以及提供和注入机制。特别强调了响应性问题的注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一, 报错情况

二,解决方案

使用createApp返回一个提供应用上下文的应用实例

createApp(App).use(router).mount('#app')

可以在其后链式调用其他方法,主要有一下几种:

 参数用法
component(组件)注册或检索全局组件。注册还会使用给定的 name 参数自动设置组件的name
use(使用)安装 Vue.js 插件。在同一个插件上多次调用此方法时,改插件将仅安装一次。
config(配置)包含应用配置的对象。同Vue2中confg。提供统一配置
directive(指
注册或检索全局指令。指令是一组具有生命周期的钩子
mixin(混入)在整个应用范围内应用混入。一旦注册,它们就可以在当前的应用中任何组件模板内使用它。插件作者可以使用此方法将自定义行为注入组件。不建议在应用代码中使用。
mount(挂载)应用实例的根组件挂载在提供的 DOM 元素上。同Vue2中的el。
provide(搭配Inject)设置一个可以被注入到应用范围内所有组件中的值。组件应该使用 inject 来接收 provide的值。 provide 和 inject 绑定不是响应式的。
unmount(卸载)在提供的 DOM 元素上卸载应用实例的根组件。

Uncaught (in promise) TypeError: error.response is undefined <anonymous> request.js:30 promise callback*_request Axios.js:163 request Axios.js:40 method Axios.js:213 wrap bind.js:5 setup Home.vue:181 callWithErrorHandling runtime-core.esm-bundler.js:199 setupStatefulComponent runtime-core.esm-bundler.js:7907 setupComponent runtime-core.esm-bundler.js:7868 mountComponent runtime-core.esm-bundler.js:5216 processComponent runtime-core.esm-bundler.js:5182 patch runtime-core.esm-bundler.js:4700 componentUpdateFn runtime-core.esm-bundler.js:5326 run reactivity.esm-bundler.js:225 setupRenderEffect runtime-core.esm-bundler.js:5454 mountComponent runtime-core.esm-bundler.js:5229 processComponent runtime-core.esm-bundler.js:5182 patch runtime-core.esm-bundler.js:4700 mountChildren runtime-core.esm-bundler.js:4932 mountElement runtime-core.esm-bundler.js:4855 processElement runtime-core.esm-bundler.js:4820 patch runtime-core.esm-bundler.js:4688 mountChildren runtime-core.esm-bundler.js:4932 mountElement runtime-core.esm-bundler.js:4855 processElement runtime-core.esm-bundler.js:4820 patch runtime-core.esm-bundler.js:4688 mountChildren runtime-core.esm-bundler.js:4932 mountElement runtime-core.esm-bundler.js:4855 processElement runtime-core.esm-bundler.js:4820 patch runtime-core.esm-bundler.js:4688 componentUpdateFn runtime-core.esm-bundler.js:5326 run reactivity.esm-bundler.js:225 setupRenderEffect runtime-core.esm-bundler.js:5454 mountComponent runtime-core.esm-bundler.js:5229 processComponent runtime-core.esm-bundler.js:5182 patch runtime-core.esm-bundler.js:4700 componentUpdateFn runtime-core.esm-bundler.js:5406 run reactivity.esm-bundler.js:225 runIfDirty reactivity.esm-bundler.js:263 callWithErrorHandling runtime-core.esm-bundler.js:199 flushJobs runtime-core.esm-bundler.js:408 promise callback*queueFlush r
最新发布
03-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值