首页 > 其他分享 >【解决报错】Invalid prop: type check failed for prop "index". Expected String with value "u

【解决报错】Invalid prop: type check failed for prop "index". Expected String with value "u

时间:2022-09-25 01:33:16浏览次数:79  
标签:index undefined prop item 报错 path

在使用elementUI循环渲染导航的过程中

<el-submenu v-for="item in hasChildren" :index="item.path+''" :key="item.path">
    <template slot="title">
      <i :class="'el-icon-'+item.icon"></i>
      <span slot="title">{{item.label}}</span>
    </template>
</el-submenu>
 
//v-bind绑定使item.path不为字符串
:index="item.path"

  浏览器报错

报错翻译:无效属性:属性“index”的类型检查失败。应为值为“undefined”的字符串,但未定义

解决方法:

将:index=“item.path”
改为:index="item.path + ’ ’ "
完美解决

原因:elementUI的index是字符串格式,加一个‘ ’,将后台数据转换为字符串

标签:index,undefined,prop,item,报错,path
From: https://www.cnblogs.com/golden-duck/p/16727118.html

相关文章