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

computed 未生效问题

computed 未生效问题

慕工程0101907 2019-04-10 18:19:10
this.$store.state数据改变后, computed未生效, 困惑了很久, 不知道哪里出了问题...感谢您的阅读和解答.1、computed    computed: {        msgInfo() {            for (var i in this.$store.state.msgList.groupMsg) {                if (this.$store.state.msgList.groupMsg[i].tid == this.$route.query.tid) {                    return this.$store.state.msgList.groupMsg[i]                }            }        }    },2、模板调用       <div class="row clearfix" v-for="item in msgInfo.msg" :key="item.mid">            <img :src="item.headerUrl" class="header">            <div class="content">                <div class="content-header" style="height:10px;">                    <p style="float:left;">{{item.fromname}}</p>                    <p style="float:right;">{{item.createtime}}</p>                </div>                <div class="clear"></div>                <p class="text" v-more>{{item.content}}</p>                <div class="content-footer">                    <p style="float:right;">--来自: {{item.groupname}}</p>                </div>                <div class="clear"></div>            </div>        </div>3、数据变更        var has = this.$store.state.msgList.groupMsg.some((item, index, array) => {            if(item.tid == data.tid){                this.$store.state.msgList.groupMsg[index].nexttime = data.create_time;                this.$store.state.msgList.groupMsg[index].msg.push({                    group : data.group,                    groupname : data.groupname,                    robotid : data.rid,                    mid : data.mid,                    from : data.from,                    fromname : data.fromname,                    content : data.content,                    headerUrl : "http://q.qlogo.cn/headimg_dl?bs=qq&dst_uin=" + data.from + "&fid=blog&spec=100",                    createtime : data.create_time                });                return true;            }        });
查看完整描述

2 回答

?
HUX布斯

TA贡献1876条经验 获得超6个赞

想要vue检测到引用类型内部的数据变化需要使用setdelete


查看完整回答
反对 回复 2019-05-19
  • 2 回答
  • 0 关注
  • 1419 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信