【IMWel训练作业】vue select component
来源:互联网 发布:德军步兵班 知乎 编辑:程序博客网 时间:2024/06/05 15:25
html代码
<div id="app"> <h2>custom select</h2> <custom-select btn-value="search" v-bind:list="list1"></custom-select> <h2>custom select2</h2> <custom-select btn-value="search2" v-bind:list="list2"></custom-select></div>
JavaScript代码
Vue.component("custom-select",{ data:function(){ return { selectShow:false, val:"" } }, props:["btnValue","list"], template:`<section class="warp"> <div class="searchIpt clearFix"> <div class="clearFix"> <input type="text" class="keyWord" v-bind:value="val" v-on:click="selectShow=!selectShow"> <input type="button" v-bind:value="btnValue"> <span></span> </div> <custom-list v-show="selectShow" v-bind:list="list" v-on:receive="changeValueHandle"></custom-list> </div> </section>`, methods:{ changeValueHandle:function(value){ this.val = value; } } }); Vue.component("custom-list",{ props:["list"], template:`<ul class="list"> <li v-for="item of list" v-on:click="selectValueHandle(item)">{{ item }}</li> </ul>`, methods:{ selectValueHandle:function(item){ this.$emit("receive",item); } } }) new Vue({ el:"#app", data:{ list1:["Beijing","Shanghai","Hangzhou"], list2:["17-04-20","17-04-21","17-04-22"] } })样式简单的添加了点,就不贴出来了,最后来一张效果图
github地址:https://github.com/Wangtaidong/vue-study/tree/master/vue_component
0 0
- 【IMWel训练作业】vue select component
- 【IMWeb训练营作业】第二次Vue作业-select component
- 【IMWeb训练营作业】vue component custom-select
- 【IMWeb训练营作业】Vue Select Demo
- 【IMWeb训练营作业】【Vue】Select组件
- 【IMWeb训练营作业】vue-select-demo
- [IMWeb训练营作业]基于vue实现的select组件
- IMWeb训练营作业--VUE练习2--select组件
- 【IMWeb训练营作业】实战vue练习之select 组件
- IMWeb训练营作业-Vue.js-select下拉菜单
- 【IMWeb训练营作业】vue demo Select组件
- 【IMWeb训练营作业】 vue练习-组件select
- IMWEB训练作业--select
- 【IMWeb训练营作业】造轮子之自己写select for vue
- 【IMWeb训练营作业】用Vue做简单的自定义select
- [IMWeb训练营作业]vue实现自定义select下拉框组件
- 【IMWeb训练营作业】Vue.js入门练习demo之select下拉菜单
- 【IMWeb训练营作业】select
- 我的面经1
- TCP的三次握手与四次挥手
- SQLite入门介绍(二)
- 二叉树的路径和
- js随机生成模拟数据
- 【IMWel训练作业】vue select component
- TurtleBot的SLAM地图构建
- Android studio怎么上传代码到Conding
- Select组件
- 量化交易 Alpha Algo 1. 简单的双均线策略
- 《重构-改善既有代码的设计》-第1例:租赁影片(2)
- MySQL数据表相关操作-完整性约束条件
- ThreadLocal与局部变量
- 马士兵java学习之路