美文网首页
Vue: Invalid prop index只接受字符串报错解

Vue: Invalid prop index只接受字符串报错解

作者: 浪男博人 | 来源:发表于2020-03-11 22:26 被阅读0次

在写Vue的时候,标签index属性必须接受字符串String类型的数据,否则会报错。

但是如果引入的数据是数字形式,则会报错:

[Vue warn]: Invalid prop: type check failed for prop "index". Expected String with value "125", got Number with value 125.

如何解决呢?

需要在标签属性的引入值后面拼接一个空的string,

原来是 index="item.id"

修改后变成 index="item.id + ' ' "

因为String和任何属性的拼接都会变成String。

相关文章

网友评论

      本文标题:Vue: Invalid prop index只接受字符串报错解

      本文链接:https://www.haomeiwen.com/subject/radkjhtx.html