<template>
<div>
<ul class="skill">
<li v-for='item of list' v-on:click='selectLi(item)'>{{item}}</li>
</ul>
</div>
</template> <script>
export default {
name:'myul',
props: ['list'],
methods: {
selectLi: function(item) {
//$emit触发当前实例上的自定义事件 receive
this.$emit('receive', item);
}
}
}
</script>
<style>
ul, li {
margin: 0;
padding: 0;
list-style: none;
}
.skill li {
font-size: 18px;
line-height: 2rem;
height: 2rem;
padding-left: 5px;
cursor: pointer;
}
.skill li:hover {
background-color: #008b45;
}
</style>
<template>
<div>
<div id="selectWrap">
<div class="searchBox">
<input type="text" :value="selectVal" @click='ulShow = !ulShow'/>
<a href="#" rel="external nofollow" class="search" v-text='btnName'></a>
</div>
<div>
<myul v-show='ulShow' v-bind:list='list' v-on:receive='changeVal'></myul>
</div>
</div>
</template> <script>
import Vue from 'vue'
import myul from './myul'
Vue.component("myul", myul)
export default {
name:'myselect',
data() {
return {
ulShow: false, //默认ul不显示,单击input改变ul的显示状态
selectVal: '' //选项值,input的值与选项值动态绑定
}
},
props: ['btnName', 'list'],
methods: {
changeVal(value) {
this.selectVal = value
}
}
}
</script>
<style>
#selectWrap {
width: 250px;
padding: 2rem;
background: #4682b4;
}
.searchBox input, .searchBox a {
line-height: 1.5rem;
height: 1.5rem;
margin-bottom: 1rem;
padding: 0 5px;
vertical-align: middle;
border: 1px solid #aaa;
border-radius: 5px;
outline: none;
}
.searchBox a {
display: inline-block;
text-decoration: none;
background-color: #b1d85c;
}
</style>

  

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import myselect from './myselect' Vue.config.productionTip = false /* eslint-disable no-new */
new Vue({
el: '#app',
data: {
data1: ['CSS', 'HTML', 'JavaScript']
},
components: {myselect},
template: "<myselect btn-name='search' v-bind:list='data1' style='float: left;margin-right: 2rem;'></myselect>" })

  

最新文章

  1. “Operation is not valid due to the current state of the object.”
  2. Linux下Nano命令使用指南
  3. Yii2 中自定义实例名称
  4. Linux下C++静态库、动态库的制作与使用
  5. Deep Learning(1)-Introduction学习总结
  6. 【mysql】关于innodb_file_format
  7. PHP 冒泡原理
  8. java 类型转json格式
  9. [转]后缀自动机(SAM)
  10. 【Unity3D】Unity自带组件—完成第一人称人物控制
  11. iOS iTunes文件共享
  12. IBUS-WARNING **: Process Key Event failed: Timeout was reached
  13. Dom学习笔记-(一)
  14. 使用ssh远程执行命令批量导出数据库到本地
  15. 在win下,如何用bat看程序运行的时间
  16. maven 项目快速下载jar方式
  17. Java 多重catch语句的具体使用介绍
  18. [No000014F]计算机编程语言家族史
  19. 透过CAT,来看分布式实时监控系统的设计与实现
  20. BZOJ 2440 [中山市选2011]完全平方数 (二分 + 莫比乌斯函数)

热门文章

  1. 解决redis运行期间key值过期但是内存memory依然占用过高
  2. 关于typescript中的枚举你需要知道这些
  3. class CAdoInterface
  4. Caesar&#39;s Legions(CodeForces-118D) 【DP】
  5. Pycharm 配置houdini
  6. 编写程序来实现实现strcat()功能
  7. 第10章:深入浅出Ansible
  8. C#通讯框架改写
  9. 解决设置了display:none的元素,会先展示再隐藏
  10. 微信小程序跳到指定页面不生效