• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >vue > Vue.js组件tree实现省市多级联动

Vue.js组件tree实现省市多级联动

作者:爱喝酸奶的吃货 字体:[增加 减小] 来源:互联网 时间:2017-05-30

本文主要包含vue.js tree,vue tree,vue el tree,vue.js组件,vue.js组件库等相关知识,爱喝酸奶的吃货 希望在学习及工作中可以帮助到您

小颖在上一篇随笔中写了两级的tree,下面给大家再分享一下用<ul><li>标签实现省市多级联动。

调用示例:

<template>
<div>
<treeview :model='treedata'></treeview>
</div>
</template>

<script>
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: '俄罗斯'
 }]}}
 }
 }
</script>
</div>

 组件代码:

<style scoped>
ul,li{
 list-style-type: none;
}

</style>
<template>
 <li>
 <div @click='toggle'><span v-if='hasLeaves'>[{{open ? '-' : '+'}}]</span>{{model.text}}</div>
 <ul>
 <treeview v-for='model in model.children' :model='model' v-show='open'></treeview>
 </ul>
 </li>
</template>

<script>
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
 }
 }
}
</script>

</div>

效果图:

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

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

</div>

您可能想查找下面的文章:

  • Vue组件tree实现树形菜单
  • Vue.js组件tree实现省市多级联动
  • Vue.js组件tree实现无限级树形菜单

相关文章

  • 2017-05-30Vue2组件tree实现无限级树形菜单
  • 2017-05-30Vue实现双向绑定的方法
  • 2017-05-30Vue 2.0+Vue-router构建一个简单的单页应用(附源码)
  • 2017-05-30vue2笔记 — vue-router路由懒加载的实现
  • 2021-12-08Vue60分钟快速入门
  • 2017-05-30Vue.js每天必学之过滤器与自定义过滤器
  • 2017-05-30vue2实现移动端上传、预览、压缩图片解决拍照旋转问题
  • 2017-05-30简单理解vue中实例属性vm.$els
  • 2017-05-30vue-router跳转页面的方法
  • 2017-05-30Vue.js系列之项目结构说明(2)

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • Vue.js仿Metronic高级表格(一)静态设计
    • Vue.js实战之Vuex的入门教程
    • vue-source的实例
    • Vue.js中用webpack合并打包多个组件并实现按需加载
    • Vue监听数组变化源码解析
    • vue+axios实现登录拦截的实例代码
    • Vue + Webpack + Vue-loader学习教程之相关配置篇
    • vue.js开发环境安装教程
    • Vue.js组件tree实现省市多级联动
    • vue学习笔记之vue1.0和vue2.0的区别介绍

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有