Vue+Vant實現(xiàn)頂部搜索欄
本文實例為大家分享了Vue+Vant實現(xiàn)頂部搜索欄的具體代碼,供大家參考,具體內(nèi)容如下
搜索欄組件源碼(SearchBar.vue)<template> <section class='city-search'> <van-icon name='search' /> <input placeholder='在此輸入檢索關(guān)鍵字' v-model='KeyWord'> <van-icon name='clear' v-show='KeyWord' @click='clearSearchInput' /> </section></template> <script>export default { data() {return { KeyWord: ’’,} }, methods: {clearSearchInput() { this.KeyWord = ’’;} }}</script> <!-- Add 'scoped' attribute to limit CSS to this component only --><style> .city-search {background-color: #F7F8FA;display: flex;justify-content: flex-start;align-items: center;height: 2.3rem;width: 94vw;margin: 2vw 4vw;border-radius: 8px; } .search-icon { margin-left: 5px; } input { margin: 0 1.5vw; background-color: #F7F8FA; border: 0px; font-size: 14px; flex: 1 } .clear-icon { color: #999;} </style>其他組件依賴引用檢索組件
首頁引用搜索組件:
<template> <div> <search></search>首頁 </div></template> <script>import Search from ’@/components/SearchBar’export default { name: 'home', components: { ’search’: Search, },}</script> <!-- Add 'scoped' attribute to limit CSS to this component only --><style> </style>
效果截圖:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 使用 kind 和 Docker 啟動本地的 Kubernetes環(huán)境2. ASP基礎(chǔ)入門第八篇(ASP內(nèi)建對象Application和Session)3. XML入門精解之結(jié)構(gòu)與語法4. Idea如何去除Mapper警告方法解析5. idea設(shè)置自動導(dǎo)入依賴的方法步驟6. IntelliJ IDEA設(shè)置編碼格式的方法7. idea設(shè)置代碼格式化的方法步驟8. idea自定義快捷鍵的方法步驟9. IntelliJ IDEA設(shè)置默認(rèn)瀏覽器的方法10. idea重置默認(rèn)配置的方法步驟
