1. Background requirements save only the last-level value
<el-cascader placeholder="Please enter"
filterable
clearable
:props="{emitPath:false}"
:options="xxList"
v-model="xxValue"
ref="cascaderXX"
@change="getCasLabel">
</el-cascader>
Copy the code
parameter | instructions | type | An optional value | The default value |
---|---|---|---|---|
emitPath | When a selected node changes, returns an array of the values of the node’s menu level. If false, returns only the value of that node | boolean | – | true |
2. If the label value is also required
onSelectIndustry () {
this.form.industryName = this.$refs.industryRef.getCheckedNodes()[0].pathLabels[(this.$refs.industryRef.getCheckedNodes()[0].pathLabels.length) - 1]},Copy the code
3. The fault is displayed
- The background only returns the ID of the last level
- The overall table of the query is written in the front end
// Item is the last level of id backfilled during editing. Parent is a local array getIndustryParentById (item, parent) { parent.map(function (value) { const res = value.children.find(x => x.value === item.industryType - 0) if (res) {// [parent id, child ID] return [value.value, res.value] } }).forEach((subItem) => { if (subItem) { this.form.industryType = subItem } }) },Copy the code