为了账号安全,请及时绑定邮箱和手机立即绑定

vue v-for循环新增对象视图不更新

vue v-for循环新增对象视图不更新

GCT1015 2019-02-15 18:12:46
如题所示,在vm中利用对象数据和v-for进行列表渲染,但是在对象数据中新增一条键值为对象的数据之后,发现视图并未更新。查看官方文档也不知道该怎么写,求大牛赐教。代码如下:    let shellObj = {};    shellObj.name = name;    shellObj.runCode = runCode;    shellObj.storePath = storePath;    if (file) {      shellObj.filePath = file.path;      fs.createReadStream(file.path)         .pipe(fs.createWriteStream(userPath + '/Shell/' + file.name))              .on('close', function () {                  shellJson[name] = shellObj;                  that.hideBlack();              });    } else {      shellObj.filePath = '';      shellJson[name] = shellObj;      that.hideBlack();    }  shellJsonCopy[name] = shellObj;  // shellJson = Object.assign(shellJson,shellJsonCopy);  body.$set(body.$data.shellData,name, shellObj);  // shellJson = Object.assign({}, shellJson, {  //     [name]: shellObj  // })
查看完整描述

1 回答

?
慕莱坞森

TA贡献1810条经验 获得超4个赞

试试 $forceUpdate() ,
vue 判断数据是否更新这部分 有点不准。

查看完整回答
反对 回复 2019-02-17
  • 1 回答
  • 0 关注
  • 949 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号