|
@@ -0,0 +1,130 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="search_bg">
|
|
|
|
+ <input type="text" class="inputsearch" v-model="name" placeholder="请输入你要搜索的内容" v-on:input="changetext">
|
|
|
|
+ <button class="sea-btn" >搜索</button>
|
|
|
|
+ <ul v-show="flag" class="item-ul">
|
|
|
|
+ <li class="item-ul-li" v-for="item in nlist" @click="getclick(item)">
|
|
|
|
+ <span class="">{{item}}</span>
|
|
|
|
+ </li>
|
|
|
|
+ </ul>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+export default {
|
|
|
|
+ name: 'search',
|
|
|
|
+ components: {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+data() {
|
|
|
|
+ return {
|
|
|
|
+ flag: false,
|
|
|
|
+ name: '',
|
|
|
|
+ nlist: [],
|
|
|
|
+ userList: [
|
|
|
|
+ {
|
|
|
|
+ name: '张三',
|
|
|
|
+ age: 18,
|
|
|
|
+ address: '中国',
|
|
|
|
+ phone: 18450994726
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: '张三',
|
|
|
|
+ age: 20,
|
|
|
|
+ address: '中国',
|
|
|
|
+ phone: 14585459455
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: '王五',
|
|
|
|
+ age: 11,
|
|
|
|
+ address: '中国',
|
|
|
|
+ phone: 12345678910
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: '李四',
|
|
|
|
+ age: 15,
|
|
|
|
+ address: '中国',
|
|
|
|
+ phone: 123456
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: '小红',
|
|
|
|
+ age: 12,
|
|
|
|
+ address: '中国',
|
|
|
|
+ phone: '暂无'
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ computed:{
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ methods:{
|
|
|
|
+ changetext () {
|
|
|
|
+ for(let i = 0;i < this.userList.length;i++ )
|
|
|
|
+ {
|
|
|
|
+ this.nlist[i]=this.userList[i].name
|
|
|
|
+ }
|
|
|
|
+ console.log(this.nlist)
|
|
|
|
+ this.flag = true
|
|
|
|
+ },
|
|
|
|
+ getclick(name){
|
|
|
|
+ this.name=name
|
|
|
|
+ this.flag= false
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <style scoped>
|
|
|
|
+ .search_bg{
|
|
|
|
+ background-color: #eaebef;
|
|
|
|
+ height: 125px;
|
|
|
|
+ }
|
|
|
|
+ .inputsearch{
|
|
|
|
+ position: absolute;
|
|
|
|
+ left: 800px;
|
|
|
|
+ top: 85px;
|
|
|
|
+ border: 1px solid #c4bebe;
|
|
|
|
+ height: 30px;
|
|
|
|
+ width: 400px;
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ padding-left: 10px;
|
|
|
|
+ }
|
|
|
|
+ input:focus{
|
|
|
|
+ border: 1px solid #c4bebe;
|
|
|
|
+ outline:none;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .item-ul {
|
|
|
|
+ border: 1px solid #c4bebe;
|
|
|
|
+ width: 392px;
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 102px;
|
|
|
|
+ left: 800px;
|
|
|
|
+ list-style: none;
|
|
|
|
+ padding: 10px;
|
|
|
|
+ background-color: white;
|
|
|
|
+ z-index: 1;
|
|
|
|
+ }
|
|
|
|
+ .item-ul-li:hover{
|
|
|
|
+ background-color: #F1F3F4;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ }
|
|
|
|
+ .sea-btn{
|
|
|
|
+ position: absolute;
|
|
|
|
+ left: 1212px;
|
|
|
|
+ top: 85px;
|
|
|
|
+ background-color: #4297E8;
|
|
|
|
+ outline:none;
|
|
|
|
+ border: 0px;
|
|
|
|
+ width: 88px;
|
|
|
|
+ height: 34px;
|
|
|
|
+ color: white;
|
|
|
|
+ font-size: 17px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ }
|
|
|
|
+ </style>
|
|
|
|
+
|