html城市二级联动vue,Vue.js组件tree实现省市多级联动

小颖在上一篇随笔中写了两级的tree,下面给大家再分享一下用

  • 标签实现省市多级联动。

    调用示例:

    import treeview from './TreeView.vue'

    export default {

    components: {

    treeview

    },

    props: {

    },

    method:{

    },

    ready:function(){

    },

    data(){

    return {

    treedata:{text:'地域',

    children: [{

    text: '中国',

    children: [{

    text: '陕西省',

    children: [{

    text: '西安市',

    children: [{

    text: '碑林区'

    }, {

    text: '雁塔区'

    }, {

    text: '未央区区'

    }, {

    text: '新城区'

    }]

    }, {

    text: '安康市'

    }, {

    text: '咸阳市',

    children: [{

    text: '秦都区'

    }, {

    text: '渭城区'

    }]

    }, {

    text: '渭南市'

    }]

    }, {

    text: '四川省',

    children: [{

    text: '成都市'

    }, {

    text: '绵阳市'

    }, {

    text: '广元市'

    }]

    }, {

    text: '安徽省'

    }]

    }, {

    text: '俄罗斯'

    }]}}

    }

    }

    组件代码:

    ul,li{

    list-style-type: none;

    }

  • [{{open ? '-' : '+'}}]{{model.text}}

export default {

name: 'treeview',

props: {

model: {

type: Object

}

},

methods: {

toggle:function(){

this.open=!this.open;

}

},

ready: function() {},

computed:{

hasLeaves: function() {

return this.model.children && this.model.children.length

}

},

data() {

return {

open: false

}

}

}

效果图:

bdaf8b4b1aec68dc70011bce22fcff52.gif

本文已被整理到了《Vue.js前端组件学习教程》,欢迎大家学习阅读。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值