zoukankan      html  css  js  c++  java
  • 搜索导航栏

    Header搜索组件:选择性CV

    router/index.js
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    import SearchCourse from '../views/SearchCourse.vue'

    const routes = [
    // ...
    {
    path: '/course/search',
    name: 'search-course',
    component: SearchCourse,
    },
    ];
    Header.vue
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    <form class="search">
    <div class="tips" v-if="is_search_tip">
    <span @click="search_action('Python')">Python</span>
    <span @click="search_action('Linux')">Linux</span>
    </div>
    <input type="text" :placeholder="search_placeholder" @focus="on_search" @blur="off_search" v-model="search_word">
    <button type="button" class="glyphicon glyphicon-search" @click="search_action(search_word)"></button>
    </form>

    <script>
    export default {
    data() {
    return {
    is_search_tip: true,
    search_placeholder: '',
    search_word: ''
    }
    },
    methods: {
    search_action(search_word) {
    if (!search_word) {
    this.$message('请输入要搜索的内容');
    return
    }
    if (search_word !== this.$route.query.word) {
    this.$router.push(`/course/search?word=${search_word}`);
    }
    this.search_word = '';
    },
    on_search() {
    this.search_placeholder = '请输入想搜索的课程';
    this.is_search_tip = false;
    },
    off_search() {
    this.search_placeholder = '';
    this.is_search_tip = true;
    },
    },
    }
    </script>

    <style scoped>
    .search {
    float: right;
    position: relative;
    margin-top: 22px;
    margin-right: 10px;
    }

    .search input, .search button {
    border: none;
    outline: none;
    background-color: white;
    }

    .search input {
    border-bottom: 1px solid #eeeeee;
    }

    .search input:focus {
    border-bottom-color: orange;
    }

    .search input:focus + button {
    color: orange;
    }

    .search .tips {
    position: absolute;
    bottom: 3px;
    left: 0;
    }

    .search .tips span {
    border-radius: 11px;
    background-color: #eee;
    line-height: 22px;
    display: inline-block;
    padding: 0 7px;
    margin-right: 3px;
    cursor: pointer;
    color: #aaa;
    font-size: 14px;

    }

    .search .tips span:hover {
    color: orange;
    }
    </style>
  • 相关阅读:
    docker file和容器数据卷,发布镜像
    Docker的镜像原理和分层理解和打包镜像
    docker部署nginx,tomcat 练习
    Docker 命令和运行原理简单剖析
    Docker安装
    Java垃圾回收-栈和堆部分知识
    aio-pika的使用
    技术基础 | 在Apache Cassandra中改变VNodes数量的影响
    行业动态 | 通过使用Apache Cassandra实现实时供应链管理
    行业动态 | Apache Pulsar 对现代数据堆栈至关重要的四个原因
  • 原文地址:https://www.cnblogs.com/plyc/p/14194307.html
Copyright © 2011-2022 走看看