码迷,mamicode.com
首页 > 其他好文 > 详细

vant 级联选择器跳坑

时间:2021-03-11 14:17:47      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:elf   cli   return   级联选择   erro   text   site   引入   picker   

<van-field readonly clickable name="calendar" :value="area" label="户籍区划" required placeholder=""
                        @click="cityShow = true">
                    </van-field>
 
<van-popup v-model="cityShow" position="bottom">
                <van-picker @cancel="cityShow = falase" show-toolbar :columns="areaList" @confirm="confirmCity">
                </van-picker>
            </van-popup>
 
setarr(item) {
                    if (!item.children) {
                        item.text = item.name
                        return item
                    } else {
                        item.text = item.name
                        item.children.forEach((sitem, sindex) => {
                            item = this.setarr(sitem)
                        })
                        return item
                    }
                },

                getareaList() {
                    var self = this;
                    let content = {
                        fun: ‘get_base_addr‘
                    }
                    axios.get(‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX‘, {
                            params: content
                        })
                        .then(function (response) {
                            self.loading = false;
                            console.log(response.data.result);
                            response.data.result.forEach((item, index) => {
                                item = self.setarr(item)
                            })
                            console.log(1111, response.data.result)
                            self.areaList = response.data.result

                        })
                        .catch(function (error) {
                            self.loading = false;
                        });
                },
 
注意vantjs的引入版本 必须在2.4.5以上才能生效

vant 级联选择器跳坑

标签:elf   cli   return   级联选择   erro   text   site   引入   picker   

原文地址:https://www.cnblogs.com/jclonely/p/14513426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!