中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

私活接單平臺windows優(yōu)化大師的優(yōu)點

私活接單平臺,windows優(yōu)化大師的優(yōu)點,c#網(wǎng)站購物車怎么做,網(wǎng)站產(chǎn)品網(wǎng)頁設計模板1、創(chuàng)建自定義組件 my-search 新版HBuilder沒有了 component 文件夾,但是有 uni_modules 文件夾,用來創(chuàng)建組件: 右鍵 uni_modules 文件夾,點擊 新建uni_modules創(chuàng)建在彈出框,填寫組件名字,例如&#xff1a…
  • 1、創(chuàng)建自定義組件?my-search

新版HBuilder沒有了 component 文件夾,但是有 uni_modules 文件夾,用來創(chuàng)建組件:

  1. 右鍵 uni_modules 文件夾,點擊 新建uni_modules創(chuàng)建
  2. 在彈出框,填寫組件名字,例如:my-search

  • 2、使用該組件

運行到微信開發(fā)者工具查看:

?修改 my-search 組件的樣式:

<template><view class="my-search-container" :style="{'background-color': bgcolor}"><view class="my-search-box" :style="{'border-radius': radius + 'px'}" @click="searchBoxHandler"><uni-icons type="search" size="17"></uni-icons><text class="placeholder">搜索</text></view></view>
</template>
<script>export default {// 別人在使用該組件時可以,傳遞搜索框外部顏色,和圓角度props: {// 背景顏色bgcolor: {type: String,default: '#C00000'},// 圓角尺寸radius: {type: Number,// 單位是 pxdefault: 18}},data() {return {}},methods: {// 點擊了模擬的 input 輸入框searchBoxHandler() {// 觸發(fā)外界通過 @click 綁定的 click 事件處理函數(shù)this.$emit('click')}}}
</script>
<style lang="scss">.my-search-container {// 移除背景顏色,改由 props 屬性控制// background-color: #C00000;height: 50px;padding: 0 10px;display: flex;align-items: center;}.my-search-box {height: 36px;background-color: #ffffff;// 移除圓角尺寸,改由 props 屬性控制// border-radius: 15px;width: 100%;display: flex;align-items: center;justify-content: center;.placeholder {font-size: 15px;margin-left: 5px;}}
</style>

某個用到 搜索框的頁面:

      // 點擊搜索跳轉 分包gotoSearch() {uni.navigateTo({url: '/subpkg/search/search'})},

?注意:我們上面搜索框,是給用戶看的,實際上,不能搜索,我們需要點擊跳轉到搜索頁面

  • 3、新建分包 search 頁面

建立一個分包:【名稱為 search】

uniapp 配置小程序分包_打不著的大喇叭的博客-CSDN博客

  • 4、使用已有的擴展uni-search-bar組件

網(wǎng)址:uni-app官網(wǎng) (dcloud.net.cn)?

<template><view><view class="search-box"><!-- 使用 uni-ui 提供的搜索組件 --><uni-search-bar @input="input" placeholder="請輸入搜索內容" clearButton="always" focus :radius="100"cancelButton="none"></uni-search-bar></view><!-- 搜索建議列表 --><view class="sugg-list" v-if="searchResults.length !== 0"><view class="sugg-item" v-for="(item, i) in searchResults" :key="i" @click="gotoDetail(item.goods_id)"><view class="goods-name">{{item.goods_name}}</view><uni-icons type="arrowright" size="16"></uni-icons></view></view><!-- 搜索歷史 --><view class="history-box" v-else><!-- 標題區(qū)域 --><view class="history-title"><text>搜索歷史</text><uni-icons type="trash" size="17" @click="cleanHistory"></uni-icons></view><!-- 列表區(qū)域 --><view class="history-list"><uni-tag :text="item" v-for="(item, i) in historys" :key="i" :inverted="true"@click="gotoGoodsList(item)"></uni-tag></view></view></view>
</template><script>export default {data() {return {// 延時器的 timerIdtimer: null,// 搜索關鍵詞kw: '',// 搜索關鍵詞的歷史記錄historyList: ['a', 'app', 'apple'],// 搜索結果列表searchResults: []};},onLoad() {this.historyList = JSON.parse(uni.getStorageSync('kw') || '[]')},computed: {historys() {// 注意:由于數(shù)組是引用類型,所以不要直接基于原數(shù)組調用 reverse 方法,以免修改原數(shù)組中元素的順序// 而是應該新建一個內存無關的數(shù)組,再進行 reverse 反轉return [...this.historyList].reverse()}},methods: {input(e) {// 清除 timer 對應的延時器clearTimeout(this.timer)// 重新啟動一個延時器,并把 timerId 賦值給 this.timerthis.timer = setTimeout(() => {// 如果 500 毫秒內,沒有觸發(fā)新的輸入事件,則為搜索關鍵詞賦值this.kw = e// 根據(jù)關鍵詞,查詢搜索建議列表this.getSearchList()}, 500)},// 點擊列表跳轉到商品列表頁面gotoDetail(goods_id) {uni.navigateTo({// 指定詳情頁面的 URL 地址,并傳遞 goods_id 參數(shù)url: '/subpkg/goods_detail/goods_detail?goods_id=' + goods_id})},// 點擊標簽跳轉到商品列表頁面gotoGoodsList(kw) {uni.navigateTo({url: '/subpkg/goods_list/goods_list?query=' + kw})},// 保存搜索關鍵詞的方法saveSearchHistory() {// 1. 將 Array 數(shù)組轉化為 Set 對象const set = new Set(this.historyList)// 2. 調用 Set 對象的 delete 方法,移除對應的元素set.delete(this.kw)// 3. 調用 Set 對象的 add 方法,向 Set 中添加元素set.add(this.kw)// 4. 將 Set 對象轉化為 Array 數(shù)組this.historyList = Array.from(set)// 調用 uni.setStorageSync(key, value) 將搜索歷史記錄持久化存儲到本地uni.setStorageSync('kw', JSON.stringify(this.historyList))},// 清空搜索歷史記錄cleanHistory() {// 清空 data 中保存的搜索歷史this.historyList = []// 清空本地存儲中記錄的搜索歷史uni.setStorageSync('kw', '[]')},// 根據(jù)搜索關鍵詞,搜索商品建議列表async getSearchList() {// 判斷關鍵詞是否為空if (this.kw === '') {this.searchResults = []return}// 發(fā)起請求,獲取搜索建議列表const {data: res} = await uni.$http.get('/api/public/v1/goods/qsearch', {query: this.kw})if (res.meta.status !== 200) return uni.$showMsg()this.searchResults = res.message// 查詢到搜索建議之后,調用 saveSearchHistory() 方法保存搜索關鍵詞this.saveSearchHistory()},}}
</script><style lang="scss">// 設置搜索框的背景顏色.uni-searchbar {background-color: #c00000;}// 設置為吸頂效果.search-box {position: sticky;top: 0;z-index: 999;}// 搜索列表.sugg-list {padding: 0 5px;.sugg-item {font-size: 12px;padding: 13px 0;border-bottom: 1px solid #efefef;display: flex;align-items: center;justify-content: space-between;.goods-name {// 文字不允許換行(單行文本)white-space: nowrap;// 溢出部分隱藏overflow: hidden;// 文本溢出后,使用 ... 代替text-overflow: ellipsis;margin-right: 3px;}}}// 搜索歷史.history-box {padding: 0 10px;.history-title {display: flex;justify-content: space-between;align-items: center;height: 40px;font-size: 13px;border-bottom: 1px solid #efefef;}.history-list {display: flex;flex-wrap: wrap;margin-top: 5px;.uni-tag {margin-top: 5px;margin-right: 5px;}}}
</style>

http://www.risenshineclean.com/news/30146.html

相關文章:

  • 鄧州網(wǎng)站建設免費廣告推廣
  • h5響應式企業(yè)網(wǎng)站源碼百度推廣客戶端下載
  • 創(chuàng)可貼網(wǎng)站怎么做圖片大全北京網(wǎng)站優(yōu)化
  • 佛山網(wǎng)站優(yōu)化公司做百度推廣代運營有用嗎
  • 包裝在線設計網(wǎng)站谷歌seo靠譜嗎
  • 哈爾濱網(wǎng)站開發(fā)培訓seo推廣代運營
  • 王者榮耀網(wǎng)站建設的步驟怎么弄一個自己的網(wǎng)站
  • 上海做公益活動有哪些好的網(wǎng)站黑帽seo是什么意思
  • 公司網(wǎng)站域名做郵箱自己做網(wǎng)站設計制作
  • 網(wǎng)站建設情況的報告國外引流推廣軟件
  • 北京h5網(wǎng)站建設報價網(wǎng)絡推廣合作協(xié)議范本
  • html入門視頻教程鄭州seo推廣優(yōu)化
  • 廈門網(wǎng)站建設培訓百度推廣開戶多少錢
  • 找人做網(wǎng)站需要注意什么跨境電商靠譜嗎
  • 做爰網(wǎng)站下載免費網(wǎng)頁制作模板
  • 如何說服老板做網(wǎng)站營銷策劃書案例
  • app軟件設計鄭州seo排名優(yōu)化公司
  • 遵義公司網(wǎng)站制作哪家好百度推廣登錄首頁網(wǎng)址
  • 如何將網(wǎng)站指向404微信5000人接推廣費用
  • 網(wǎng)站如何做促銷活動推廣引流話術
  • 山東網(wǎng)站建設公司武漢做seo公司
  • 網(wǎng)站建設歸工商局管還是工信局管查關鍵詞排名軟件
  • 代做網(wǎng)站排名谷歌優(yōu)化推廣
  • 網(wǎng)站建設哪家最專業(yè)長沙網(wǎng)絡營銷學校
  • 定制開發(fā)app到底要多少錢百度搜索引擎優(yōu)化指南最新版
  • 南海網(wǎng)站建設公司蘇州網(wǎng)站優(yōu)化排名推廣
  • 怎么查看網(wǎng)站收錄東營seo
  • 哪個新聞網(wǎng)站好友情鏈接是啥意思
  • 做美工一般要收藏哪些網(wǎng)站友情鏈接軟件
  • wordpress tag 收錄肇慶seo按天收費