【vue报错】 [Vue warn]: Invalid prop: type check failed for prop “index“. Expected String, got Undefined

问题描述

【vue报错】 [Vue warn]: Invalid prop: type check failed for prop “index“. Expected String, got Undefined_第1张图片
在使用第三方组件element-ui的el-menu组件,设置index时,有时候控制台会报错 [Vue warn]: Invalid prop: type check failed for prop "index". Expected String, got Undefined,虽然不影响功能和ui的渲染,但是本着严谨的原则,有问题,咱们还是得解决。先把解决方法和问题产生的原因和大家分享。

废话不多说,直接上代码…

代码展示

【vue报错】 [Vue warn]: Invalid prop: type check failed for prop “index“. Expected String, got Undefined_第2张图片

问题产生的原因

属性无效:属性“索引”的类型检查失败。预期字符串,未定义,通俗的说,就是index绑定的动态数据不能被检索为字符串。

解决问题

将index绑定的数据手动变为字符串即可 index=item.path+''·
【vue报错】 [Vue warn]: Invalid prop: type check failed for prop “index“. Expected String, got Undefined_第3张图片

问题完美解决✌✌✌

【vue报错】 [Vue warn]: Invalid prop: type check failed for prop “index“. Expected String, got Undefined_第4张图片

你可能感兴趣的:(vue报错系列,Vue,javascript,vue.js,前端,笔记)