Invalid prop: type check failed for prop "width". Expected String with value "1500", got Number with value 1500.
时间: 2023-10-18 08:31:05 浏览: 102
2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop “index”.
5星 · 资源好评率100%
这个错误信息是指在组件中的prop验证中,属性"width"的预期类型为字符串型,值为"1500",但实际传入的是数值型1500,导致验证失败。
解决这个问题的方法是将数值类型的"width"转换为字符串型。你可以通过在代码中使用toString()方法或者在模板中使用字符串插值来实现这一转换。例如,你可以将原来的代码中的width属性值改为"1500"(用引号括起来),或将它转换成字符串形式"1500"。这样就能满足prop的预期类型验证了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Invalid prop:type check failed for prop.Expected String with value“[object Object]”got Object](https://blog.csdn.net/qq_45796592/article/details/131870831)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [Invalid prop:type check failed for prop“value“.Expected String with value“8“,got Number with ...](https://blog.csdn.net/m0_46467215/article/details/126082209)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文