小編給大家分享一下微信小程序如何實(shí)現(xiàn)搜索功能并跳轉(zhuǎn)搜索結(jié)果頁面,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
微信小程序?qū)崿F(xiàn)搜索功能,并跳轉(zhuǎn)搜索結(jié)果頁面,具體內(nèi)容如下
搜索頁面:
search.wxml頁面:
<view class="form"> <input class="searchInput" value='{{keyWord}}' bindconfirm='goSearch' placeholder="請輸入搜索關(guān)鍵字" type="text" /> </view>
search.wxss樣式:
.form { position: relative; height: 40px; } .searchInput { border: 1px solid #2c3036; height: 40px; line-height: 40px; font-size: 14px; border-radius: 20px; color: #bebec4; padding-left: 35px; }
search.js:
// 搜索 goSearch: function(e) { var that = this; var formData = e.detail.value; if (formData) { wx.request({ url: 'https://xxxxx/homepage/search', data: { title: formData }, header: { 'Content-Type': 'application/json' }, success: function(res) { that.setData({ search: res.data, }) if (res.data.msg=='無相關(guān)視頻'){ wx.showToast({ title: '無相關(guān)視頻', icon: 'none', duration: 1500 }) }else{ let str = JSON.stringify(res.data.result.data); wx.navigateTo({ url: '../searchShow/searchShow?data=' + str }) } // console.log(res.data.msg) } }) } else { wx.showToast({ title: '輸入不能為空', icon: 'none', duration: 1500 }) } }
搜索結(jié)果:
searchShow.wxml頁面:
<view class="container"> <view class="listBox" wx:for="{{searchShow}}" wx:key="{{item.id}}"> <view class="listMain"> <navigator url='../videoShow/videoShow?id={{item.id}}'> <image src="{{item.image}}" mode="widthFix"></image> <view class='listTitle'> <view class="listSubtitle"> <text>{{item.title}}</text> </view> <view class="listText"> <text>{{item.decription}}</text> </view> </view> </navigator> </view> </view> </view> searchShow.js onLoad: function(options) { let searchShow = JSON.parse(options.data); let that = this that.setData({ searchShow: searchShow }) console.log(searchShow) },
以上是“微信小程序如何實(shí)現(xiàn)搜索功能并跳轉(zhuǎn)搜索結(jié)果頁面”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)頁名稱:微信小程序如何實(shí)現(xiàn)搜索功能并跳轉(zhuǎn)搜索結(jié)果頁面-創(chuàng)新互聯(lián)
文章網(wǎng)址:http://aaarwkj.com/article40/dspsho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、電子商務(wù)、建站公司、網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容