vue數組中某個鍵的重複性驗證

      //選項重複驗證
      isRepeat() {
        let list = this.addform.xuanxiang
        let arr = list.map(item => item.xx_mingcheng);
        let new_arr = Array.from(new Set(arr));
        if (new_arr.length < arr.length) {
          this.$message.error('選項不能重複')
          return false
        }
      }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章