【vue】解决Property ‘xxx‘ does not exist on type ‘never‘

做一个根据id返回对应名称的过滤函数,记录如下报错

报错:Property 'xxx' does not exist on type 'never'.Vetur(2339)
【vue】解决Property ‘xxx‘ does not exist on type ‘never‘_第1张图片
我获取到的数据是:{__ob__: we}对象形式的数组
【vue】解决Property ‘xxx‘ does not exist on type ‘never‘_第2张图片

解决方法:通过字符方式获取对象属性【来自大神:EsquireY】

growthStageFormat(id){
      let label = '';
      // 重点来啦
      this.stepAttr.find((item) => {
        if (item["growthStageId"] == id) {
          label = item["stageName"]
        }
      });
      return label
    },

【vue】解决Property ‘xxx‘ does not exist on type ‘never‘_第3张图片
显示正常OOKK!

你可能感兴趣的:(css,html,javascript)