elemen-ui的el-select 點擊觸發事件change


elemen-ui的el-select 點擊觸發事件change

template部分
<el-form-item label="所屬部門" prop="department" class="jobinput">
              <el-select v-model="publishInfo.department" placeholder="請選擇部門" @change="getCategoryOptions">
                <el-option
                  v-for="item in departmentOptions"
                  :key="item.department_id"
                  :label="item.departmentName"
                  :value="item.department_id">
                </el-option>
              </el-select>
            </el-form-item>
getCategoryOptions(id) {
     //能獲取到publishInfo.department的值就是id
      console.log(id)
      fetch.getCategoryOptions(id).then(res => {
        if (res.status === 200) {
          // console.log(res.data.categories)
          if (res.data.categories.length === 0) {
            this.$message({
              message: "部門下沒有分類",
              type: 'success'
            })
          }
          else {
            this.categoryOptions = res.data.categories
          }

        }
      }).catch(e => {
        console.log(e)
      })
    }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM