子组件传参,得不到响应

1.因为在父组件页面是,已经创建了子组件,所以子组件挂载在monted的数据只会触发一次(父组件页面刷新的那一次);所以对我们之后操作子组件的信息就非常不舒服。

2.我们可以用watch进行监听数据,随后在更改子组件信息时重新调取接口就行。

 props: ["lastDetails"],
  watch: {
    lastDetails: {
      immediate: true, //立马监听
      handler(newvalue, oldvalue) {
        this.steps = this.lastDetails.children.length;
        this.lastDetailsId = this.lastDetails.id;
        this.rank = JSON.parse(localStorage.getItem("id")).role.rank;
        this.userId = JSON.parse(localStorage.getItem("id")).id;
        this.Activename = JSON.parse(localStorage.getItem("id")).name;
        this.listData = this.lastDetails.newsinfo.pics;
        this.childUser = this.lastDetails.children;
        this.childbom();
      },
    },
  },

3.批注完,立马调用接口,watch重新监听数据,进行渲染

// 领导确定批注
    confirm() {
      this.$api.leader_infos(this.leader).then((res) => {
        if (res.message == "操作成功!") {
          this.$toast.success({
            message: "批注成功",
          });
        }
      });
      this.$api.Turn_NewsDetails(this.lastDetailsId).then((res) => {
        this.lastDetails = res;
      });
    },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值