IMWeb训练营作业,自定义 select
来源:互联网 发布:mac服务器ip地址查询 编辑:程序博客网 时间:2024/06/08 00:21
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>自定义 select</title>
<script src="vue.js"></script>
<style type="text/css">
.warp{
}
</style>
</head>
<body>
<div class="content">
<custom-select btn-value="搜索" :list="list"></custom-select>
</div>
<script>
Vue.component("custom-select",{
data:function () {
return {
selectshow:false,
val:""
}
},
props:["btnValue","list"],
template:`<section class="warp"><div>
<div>
<input type="text" :value="val" @click="selectshow=!selectshow"/>
<input type="button" :value="btnValue" />
</div>
<custom-list
v-show="selectshow"
@receive="chanageValHandle"
:list="list"
></custom-list>
</div>
</section>`,
methods:{
chanageValHandle(value){
this.val=value;
}
}
});
Vue.component("custom-list",{
props:["list"],
template:`<ul>
<li v-for="item of list" @click="sltvalHandle(item)">{{item}}</li>
</ul>`,
methods:{
sltvalHandle:function(item){
this.$emit("receive",item);
}
}
new Vue({
el:".content",
data:{
list:["北京","上海","广州","杭州"],
}
});
</script>
</body>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>自定义 select</title>
<script src="vue.js"></script>
<style type="text/css">
.warp{
}
</style>
</head>
<body>
<div class="content">
<custom-select btn-value="搜索" :list="list"></custom-select>
</div>
<script>
Vue.component("custom-select",{
data:function () {
return {
selectshow:false,
val:""
}
},
props:["btnValue","list"],
template:`<section class="warp"><div>
<div>
<input type="text" :value="val" @click="selectshow=!selectshow"/>
<input type="button" :value="btnValue" />
</div>
<custom-list
v-show="selectshow"
@receive="chanageValHandle"
:list="list"
></custom-list>
</div>
</section>`,
methods:{
chanageValHandle(value){
this.val=value;
}
}
});
Vue.component("custom-list",{
props:["list"],
template:`<ul>
<li v-for="item of list" @click="sltvalHandle(item)">{{item}}</li>
</ul>`,
methods:{
sltvalHandle:function(item){
this.$emit("receive",item);
}
}
});
new Vue({
el:".content",
data:{
list:["北京","上海","广州","杭州"],
}
});
</script>
</body>
</html>
0 0
- 【IMWeb训练营作业】自定义 Select
- 【IMWeb训练营作业】自定义Select
- IMWeb训练营作业,自定义 select
- 【IMWeb训练营作业】select
- IMWeb训练营作业----select
- IMWeb训练营作业-Select
- 【IMWeb训练营作业】Select
- 【IMWeb训练营作业】select
- IMWeb训练营作业-select
- IMWeb训练营作业 select
- IMWEB训练作业--select
- IMWeb训练营作业------仿SELECT
- 【IMWeb训练营作业】select 组件初版
- 【IMWeb训练营作业】select组件
- 【IMWeb训练营作业】Select组件
- 【IMWeb训练营作业】Vue Select Demo
- IMWeb训练营作业-仿select组件
- 【IMWeb训练营作业】select 组件
- 权限管理——RBAC模型总结
- json_encode()
- Linux声卡驱动分析
- Javascript中布尔类型转换及返回false的参数
- C#中当参数为空时的几种处理
- IMWeb训练营作业,自定义 select
- Java基础
- MyBatis学习 之 二、SQL语句映射文件(2)增删改查、参数、缓存
- C++实现委托机制(一)
- 【BZOJ2038】小Z的袜子(2009国家集训队)-莫队算法
- The server does not support version 3.0 of the J2EE Web module specification
- SPRING 的任务调度
- JavaBean技术
- [已解决]Android 5.1 上面进行debug的时候 debug 的界面总是不消失 一直显示 Application is waiting for the debugger to attach