Vue3报错处理合集
目录
2、vue2 升级到 vue3 router 动态授权路由 异步加载报错 TypeError Cannot read properties of undefined (reading ‘apply‘)
3、Do not access Object.prototype method 'hasOwnProperty' from target object
6、Type 'string' is not assignable to type 'never'
这些报错是我在自己按照vue-admin-template的模板,自己改编成vue3-elementPlus-admin后台模板的时候遇到的一些报错,在这里记录下来。
1、Getting a value from the `props` in root scope of `setup()` will cause the value to lose reactivity
添加以下注释即可
-
/* eslint-disable */
-
// eslint-disable-next-line vue/no-setup-props-destructure
2、vue2 升级到 vue3 router 动态授权路由 异步加载报错 TypeError Cannot read properties of undefined (reading ‘apply‘)
原本:
(resolve: any) => require([`@/views/${v.component}`], resolve)
改成:
() => require.ensure([], (require) => require(`@/views/${v.component}`))
3、Do not access Object.prototype method 'hasOwnProperty' from target object
原本的:
v.hasOwnProperty('items')
改成:
Object.prototype.hasOwnProperty.call(v, 'items')
4、vue中使用element-ui 菜单栏(el-menu)点击双击两次才高亮的bug
原因:default-active和index属性不一致导致的
解决方法:使用路由的name属性设置给index和default-active
5、vue2项目转换到vue3
禁用Vetur
安装插件Vue Language Features (Volar)
6、Type 'string' is not assignable to type 'never'
上面提示的意思就是:类型“string[]”不能分配给类型“never[]”。
原因:如果ts中声明变量时没有声明类型,默认的话会是never[],而其他类型不能分配给类型never[],
Never的意思是其它类型(包括 null 和 undefined)的子类型,代表从不会出现的值。
-
const data = reactive({
-
tableData: [] as any[],
-
tableColumns: [] as any[]
-
});
7、类型“{}”上不存在属性“img”
-
const data = reactive({
-
info: {},
-
});
-
function GetFromData() {
-
data.info={img:'png'}
-
}
-
-
console.log(data.info.img);//报错
-
console.log(data.info['img']);//不报错
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhggcbgg
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01