1. Effect Function: Use the data retrieved from the interface to display the optional items and start with the default option values. 2. Main code<el-cascader ref="cascaderAddr" :options="rangeArr" :props="optionProps" v-model="plable" @change="handleChange3" style="width: 100%;"></el-cascader> explain: (1) The data source does not conform to the official data source and needs to be redirected But the data source returned by our interface is as follows: So we need to re-point to the value, label and children values (hence: props="optionProps"); (2) expandTrigger: The expansion method of the secondary menu is click/hover. The default is click. (3) checkStrictly: Whether to strictly abide by the principle that parent and child nodes are not related to each other export default { data() { // Delivery location selection source rangeArr: [], optionProps: { value: 'sguid', label: 'address', children: 'childs', checkStrictly: true, expandTrigger: 'hover' }, plable: [], //delivery selection value}, mounted: function() { //Delivery location this.$axios .get('url') .then(response => { this.rangeArr = response.data.obj; console.log('Delivery can choose source aaaa', this.rangeArr); }) .catch(function(error) { // Request failure processing console.log(error); }); //Get the initial value this.$axios.get("url") .then((response) => { if (response.data.status == 200){ this.plable=response.data.obj.ranges_sguid;//Default selected value } }) .catch(function (error) { // Request failure processing console.log(error); }); }, methods: { handleChange3(value) { console.log('select id value',value); console.log('Select label value',this.plable); var thsAreaCode = this.$refs.cascaderAddr.getCheckedNodes()[0].pathLabels;; //Note 2: Get label value console.log('lable',thsAreaCode) // Note 3: The final result is a one-dimensional array object var len=value.length-1; this.form.ranges_sguid=value[len];//This is the final modified selected data value to be submitted console.log('guid',this.form.ranges_sguid); this.$refs.cascaderAddr.toggleDropDownVisible(); // After selecting, collapse the drop-down interface } } This is the end of this article about the practice of el-cascader cascade selector in elementui. For more relevant element el-cascader cascade selector content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
Detailed explanation of creating MySql scheduled ...
Use the following command to create a container a...
The latest Perfect Aloe Vera Gel packaging box ha...
Although Microsoft provides T4 templates, I find ...
Writing a Dockerfile Configure yum source cd /tmp...
This article shares the installation and configur...
Last time, we came up with two header layouts, on...
In the path of using nginx as a reverse proxy tom...
Preface: In project development, some business ta...
How to implement Mysql switching data storage dir...
Preface The blogger uses the idea IDE. Because th...
Enable WSL Make sure the system is Windows 10 200...
Table of contents event Page Loading Event Delega...
This article shares the specific code of node+soc...
Example: tip: This component is based on vue-crop...