vue同级传参

a:orderOrder:function () {

   this.GLOBAL.order.$emit("orderList",this.oderList[j]);
   this.$router.push({path:"/orders/orderOrders"});
    },
                   

b: mounted:function () {

       this.GLOBAL.order.$on('orderList',(data)=>{
            console.log(data);
        });
    }
    
    不知道为什么第一张图片上传不了,第一次console是空,然后返回再传就出现了一个值一次空值,再一次就是两个值和一个空值

为什么第一次是空值,之后又每次会多次console?

clipboard.png

clipboard.png

阅读 2.2k
2 个回答

这个 出现空值是由于 数据没有接收到 但是渲染mounted 挂载时执行一次

第二次 同样执行一次空值 然后$emit 一次值 route路由更新 一次值

this.GLOBAL.order.$emit("orderList",this.oderList[j]);
this.$router.push({path:"/orders/orderOrders"});

什么意思??

先emit 一个事件??然后跳转,orderOrders如果还没有加载,谁来处理

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题