Vue笔记

点击查看vue整理
vue实现一个三级联动的城市列表 
其实第一步就是flex布局好三局联动的layout,之后就是请求数据实时更新城市列表的内容,默认情况下的内容都是取到第一列表城市显示,其他的联动绑定点击事件请求接口即可,一下是代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>cityInfo</title>
    <script src="https://cdn.bootcss.com/vue/2.4.2/vue.js"></script>
    <style>
        .cityBox{
            width:600px;
            display:flex;
            height:400px;
        }
        .cityList{
            width:100px;
            flex:0 100px;
        }
        .areaList{
            width:150px;
            flex:0 150px;
        }
        .stationList{
            width:200px;
            flex:0 200px;
        }
    </style>
</head>
<body>
<div id="cityExample" class="cityBox">
    <div class="cityList">
        <div v-for="(item ,index) in cityList" :key="index" @click="tabChange()">{{item}}</div>
    </div>
    <div class="areaList">
        <div v-for="(item ,index) in areaList" :key="index">{{item}}</div>
    </div>
    <div class="stationList">
        <div v-for="(item ,index) in stationList" :key="index">{{item}}</div>
    </div>
</div>
<script>
    new Vue({
        el:'#cityExample',
        data:{
            cityList:[
               '城市1','城市2','城市3'
            ],
            areaList:['浦东','黄浦','闵行','徐汇'],
            stationList:['南京东西','虹桥','火车站','汽车站','fengxian'],
        },
        methods:{
            tabChange(){
                //去请求某接口更新值即可
                this.areaList=['1','1','2','3','4','5']
                this.stationList=['10','10','20','30','40','50']
            }
        }
    })
</script>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值