Invalid prop: type check failed for prop "currentPage". Expected Number with value NaN, got PointerEvent
时间: 2023-10-18 11:30:01 浏览: 156
官方资料:Oracle 11g中的信息集成.pdf
根据引用和引用的内容可知,问题出现在将从localStorage中获取的数据赋值给currentPage变量时,由于存储时是int类型,取出时变成了string类型,导致了类型冲突。解决方法是在获取localStorage数据时,使用parseInt()函数将其转换为int类型,以保持前后变量赋值一致。具体代码如下所示:
```
let localstorage_current_page = 1; //初始化为1,若一开始localStorage没有缓存,则显示首页面。
if(localStorage.getItem("current_page")){
this.current_page = parseInt(localStorage.getItem("current_page"));
localstorage_current_page = parseInt(localStorage.getItem("current_page"));
}
```
这样就可以解决Invalid prop: type check failed for prop "currentPage"的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [[Vue warn]: Invalid prop: type check failed for prop “currentPage“. Expected String with value “1...](https://blog.csdn.net/qq_44267691/article/details/127247351)[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_1"}}] [.reference_item style="max-width: 50%"]
- *3* [2020-web前端-vue项目出错-[Vue warn]: Invalid prop: custom validator check failed for prop “index”.](https://download.csdn.net/download/weixin_38675797/14043780)[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_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文