vue.js 中的对象如何解析啊?

  1. 为什么vuejs为什么不能正常的解析啊,

可以输出对象

computed: {
    label () {
      var temp = this.useroptions.filter(item => { return item.bActive === true })
      console.log(temp[0])
    }
  },

图片描述

但是解析对象的时候却出错了

 computed: {
    label () {
      var temp = this.useroptions.filter(item => { return item.bActive === true })
      console.log(temp[0]['label'])
    }
  },

图片描述

阅读 3.9k
2 个回答

this.useroptions的数据结构给一下。应该是你代码的问题,报错的提示很明显了。

分开写

let temp0 = temp[0];
console.log(temp0.label);
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题