vue.js 遍歷數組並加上disabled屬性


 getMemberRole() {
    fetchRole().then(response => {
      this.roleOptions = response.data.items
      var self = this
      this.roleOptions.forEach(function(item, index) {
        if (item.parent_id == 0 && item.id != 1) {
          self.roleOptions[index]['disabled'] = true
        } else {
          self.roleOptions[index]['disabled'] = false
        }
      })
    })
  },
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章