在for循环动态赋值的时候发现有部分数据赋值失败,下面给大家介绍一下解决方法!
数组赋值失败
for (let i = 0; i < _thisR.length; i++) {
for (let j = 0; j < _thisA.length; j++) {
if (_thisR[i].typeValue == _thisA[j].value) {
//_thisR[i].list = constant[_thisA[j].options];赋值成功靠运气,彻底解决方法用下面的
_thisR[i].list = [...constant[_thisA[j].options]];
this.$forceUpdate();
}
}
}
值已经存在,但子组件获取的数据是空
方法一:
//template
{{ checkRulesLabel }}
//props
props: {
checkRulesLabel: {
type: String,
default: function() {
return "";
}
}
},
//watch
watch: {
checkRulesLabel() {}
}
方法二:
//如果需要传参到data
//template
{{ title }}
//props
props: {
checkRulesLabel: {
type: String,
default: function() {
return "";
}
}
},
//data
data() {
return {
title: ""
};
},
//watch
watch: {
checkRulesLabel: {
handler(val) {
this.title = val;
},
immediate: true
}
}
以上是编程学习网小编为您介绍的“vuejs子组件赋值失败解决方法”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。
织梦狗教程
本文标题为:vuejs子组件赋值失败解决方法


基础教程推荐
猜你喜欢
- vue 快速入门 系列 —— 侦测数据的变化 - [基本实现] 2023-10-08
- 使用CSS的table-cell属性实现左图右文的排版方法详解 2024-03-10
- new Vue() vs createApp() 2023-10-08
- vue-cli脚手架卸载与安装代码总结 2025-01-15
- 前端(HTML)+后端(Django)+数据库(MySQL):用户注册及登录演示 2023-10-26
- 关于 html:创建社交媒体图标 2022-09-21
- javascript实现跟随鼠标移动的图片 2023-12-21
- Nodejs 连接 mysql时报Error: Cannot enqueue Query after fatal error错误的处理办法 2023-07-09
- CSS3中的opacity属性使用教程 2023-12-28
- 2个数组根据相同key合并成新的数组(es5、es6两种 2024-12-08