Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决

简介: Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决

前几天一个月薪35k的兄弟,给我推了一个人工智能学习网站,看了一段时间挺有意思的。包括语音识别、机器翻译等从基础到实战都有,很详细,分享给大家。大家及时保存,说不定啥时候就没了。

Invalid prop: type check failed for prop “index”. Expected String with value "5"问题解决

在elementUI导航组件中加入后台数据驱动循环生成导航时会报如下错误

这里的错误是由index引起的,index的值必须是字符串,而且是单一的。

源代码

<el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
      <el-submenu index="1">
        <template slot="title">导航一</template>
          <el-menu-item index="1-1">选项1</el-menu-item>
          <el-menu-item index="1-2">选项2</el-menu-item>
      </el-submenu>
    </el-menu>

解决

将index的值转化为字符串格式

可以这么干::index=“String(index)”

也可以这么干::index=" index + ’ ’ "

目录
相关文章
|
4月前
|
前端开发 Java 数据库连接
Spring Boot 升级 3.2 报错 Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String
Spring Boot 升级 3.2 报错 Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String
解决方案:Missing URI template variable ‘userName‘ for method parameter of type String
解决方案:Missing URI template variable ‘userName‘ for method parameter of type String
|
6月前
解决Missing cookie ‘JssionId‘ for method parameter of type String问题
解决Missing cookie ‘JssionId‘ for method parameter of type String问题
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
Error: Element type is invalid: expected a string (for built-in components) or a class/function
2311 0
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
|
4月前
Excel上传出错:TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string or an instan
Excel上传出错:TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string or an instan
|
5月前
|
编译器
error TS2322 Type ‘string null‘ is not assignable to type ‘string undefined‘.
error TS2322 Type ‘string null‘ is not assignable to type ‘string undefined‘.
91 1
|
6月前
|
XML 数据格式
解决 Cannot convert value of type ‘java.lang.String‘ to required type ‘java.sql.Driver‘ for property ‘
解决 Cannot convert value of type ‘java.lang.String‘ to required type ‘java.sql.Driver‘ for property ‘
123 0
|
8月前
|
JSON 数据格式
Required request parameter ‘name‘ for method parameter type String is not present 报错解决方法
Required request parameter ‘name‘ for method parameter type String is not present 报错解决方法
3339 0
|
9月前
|
Java
【报错】String cannot be resolved to a type解决方案
【报错】String cannot be resolved to a type解决方案
212 1
|
Java Spring 容器
No qualifying bean of type ‘java.lang.String‘ available: expected at least 1 bean which qualifies
No qualifying bean of type ‘java.lang.String‘ available: expected at least 1 bean which qualifies
733 0
No qualifying bean of type ‘java.lang.String‘ available: expected at least 1 bean which qualifies