zoukankan      html  css  js  c++  java
  • vue elementui二级联动下拉选项demo

    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <title>Document</title>
    </head>

    <body>
    <div id="app">
    <el-select v-model="province" placeholder="请选择" @change="selectChange">
    <el-option v-for="item in compony" :key="item.code" :label="item.name" :value="item.code">
    </el-option>
    </el-select>
    <el-select v-model="city" placeholder="请选择">
    <el-option v-for="item in newCity" :key="item.code" :label="item.name" :value="item.code">
    </el-option>
    </el-select>
    </div>
    <script>
    let vm = new Vue({
    el: '#app',
    data() {
    return {
    province:"",
    city:"",
    newCity:[],
    compony: [{
    "code": 1,
    "name": '区域1',
    "childrens": [{
    "code": 01,
    "name": '广东'
    },{
    "code": 02,
    "name": '江西'
    }],
     
    },
    {
    "code": 2,
    "name": '区域2',
    "childrens": [{
    "code": 03,
    "name": '北京'
    },{
    "code": 04,
    "name": '东'
    }
    ],
     
    }]
    }
    },
    methods: {

    selectChange(value){
    console.log(value);
    this.newCity = this.compony[value-1].childrens
    this.city = this.newCity[0].name
    console.log(this.newCity[0],'newcity')
     
    }
    }

    })
    </script>
    </body>

    </html>
  • 相关阅读:
    CodeForces 446A. DZY Loves Sequences(最长上升子序列)
    CodeForces
    2020牛客暑期多校训练营(第一场)
    POJ3281-Dining(最大流)(拆点)
    「杂题」图论杂题选做
    「学习小结」CDQ 分治多维偏序问题
    「算法笔记」Tarjan 算法 双连通分量
    「算法笔记」状压 DP
    「算法笔记」数位 DP
    「算法笔记」矩阵乘法
  • 原文地址:https://www.cnblogs.com/lan-cheng/p/9215386.html
Copyright © 2011-2022 走看看