Mint-UI Picker 三级联动
2018-06-24 00:57:55来源:未知 阅读 ()
Mint-UI Picker组件的三级联动
HTML:
<mt-picker :slots="slots" value-key="name" @change="onValuesChange"></mt-picker>
JS:
const address = [ { "code": "001", "name": "省份1", "childs": [ { "code": "001-1", "name": "城市1", "childs": [ { "code": "001-1-1", "name": "城市1县城1" }, { "code": "001-1-2", "name": "城市1县城2" } ] }, { "code": "001-2", "name": "城市2", "childs": [ { "code": "001-2-1", "name": "城市2县城1" }, { "code": "001-2-2", "name": "城市2县城2" } ] } ] }, { "code": "002", "name": "省份2", "childs": [ { "code": "002-1", "name": "城市3", "childs": [ { "code": "002-1-1", "name": "城市3县城1" }, { "code": "002-1-2", "name": "城市3县城2" } ] }, { "code": "002-2", "name": "城市4", "childs": [ { "code": "002-2-1", "name": "城市4县城1" }, { "code": "002-2-2", "name": "城市4县城2" } ] } ] }, { "code": "003", "name": "省份3", "childs": [ { "code": "003-1", "name": "城市5", "childs": [ { "code": "003-1-1", "name": "城市5县城1" }, { "code": "003-1-2", "name": "城市5县城2" } ] }, { "code": "003-2", "name": "城市6", "childs": [ { "code": "003-2-1", "name": "城市6县城1" }, { "code": "003-2-2", "name": "城市6县城2" } ] } ] }, ];
export default { name: 'app', data () { return { myAdress:null, slots: [ { flex: 1, values: address, defaultIndex:10, className: 'slot1', textAlign: 'right' }, { divider: true, content: '-', className: 'slot2' }, { flex: 1, values: address[0].childs, defaultIndex:0, className: 'slot3', textAlign: 'left' }, { divider: true, content: '-', className: 'slot4' }, { flex: 1, values: address[0].childs[0].childs, defaultIndex:0, className: 'slot5', textAlign: 'left' } ] } }, methods: { onValuesChange(picker, values) { if(!values[0]){ this.$nextTick(()=>{ if(this.myAdress){ // 赋默认值 }else{ picker.setValues([address[0],address[0].childs[0],address[0].childs[0].childs[0]]) } }); }else{ picker.setSlotValues(1, values[0].childs); let town = []; if(values[1]){ town = values[1].childs; } picker.setSlotValues(2,town); } } } }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- 2.省市区,三级联动(注释详解)。 2019-05-13
- VUE 采坑之旅-- Mint-ui 按需引入报出Module build failed: 2019-02-21
- vue 引入 mint-ui 简单使用 2019-01-21
- 三级联动 2018-12-27
- bootstrap-daterangepicker插件运用 2018-09-05
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash