Vue+Vant實(shí)現(xiàn)頂部搜索欄
本文實(shí)例為大家分享了Vue+Vant實(shí)現(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>其他組件依賴引用檢索組件
首頁(yè)引用搜索組件:
<template> <div> <search></search>首頁(yè) </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>
效果截圖:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 告別AJAX實(shí)現(xiàn)無(wú)刷新提交表單2. css代碼優(yōu)化的12個(gè)技巧3. Vue+elementUI下拉框自定義顏色選擇器方式4. 使用css實(shí)現(xiàn)全兼容tooltip提示框5. css進(jìn)階學(xué)習(xí) 選擇符6. 低版本IE正常運(yùn)行HTML5+CSS3網(wǎng)站的3種解決方案7. Xml簡(jiǎn)介_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理8. CSS hack用法案例詳解9. CSS3實(shí)例分享之多重背景的實(shí)現(xiàn)(Multiple backgrounds)10. ASP中常用的22個(gè)FSO文件操作函數(shù)整理
