javascript - 无法导航到 vue.js 中多页面表单中的下一页
问题描述
我无法导航到 vue.js 中多页面表单的下一页。
name: 'xxx',
data: ()=>{
return{
currentPage: -1,
text: "Hello"
}
},
}
在 vue 模板中绑定 CurrentPage,如下所示:
<div class="container" v-for="(pages, pageid) in pages_json" :currentPage="currentPage" v-if="currentPage== pageid">
根据currentPage值,相应地显示表单。值从 -1 开始。每次点击vue.js 模板中的NEXT 按钮时,都需要更新 CurrentPage 。
this.$root.$validator.validate(scope + '.*').then(valid => {
if (valid){
if(text == "Hello"){
this.currentPage += 1;
}
else{
// throwing error here, since assigning value to this.currentPage
this.currentPage = 1;
console.log(this.currentPage) // updating perfectly here
}
});
上面的代码用于在NEXT 按钮单击时调用的方法中。为 [else block] 内的 vue 数据赋值会引发错误。
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined"
解决方案
推荐阅读
- python - 超过 79 个字符与评论一致
- node.js - Mongoose:从另一个子文档和人口中引用一个子文档
- json - 如何使用Vue axios无限滚动从json获取数据列表
- java - 是否有可能丢失数据或 Ignite Cache 中的不同键上存在不同的数据?
- java - 无法将文件放入 Java 字节数组
- c - 通过c将密码输入终端
- python - django中的cookiecutter错误
- firebase - Firebase:通过云功能检查用户电子邮件是否经过验证
- python - 如何创建一个快速的 Python GUI 来控制用于面部检测的网络摄像头输入?
- amazon-web-services - 如何正确(可扩展地)将许多 ORC 文件读入 spark