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)
})
}