wxml
<view class="index-search container-class">
<view class="search-icon icon-class"></view>
<input bindconfirm="onConfirm" bindinput="onInput" class="search-input input-class" confirmType="search"
focus="{{autoFocus}}" placeholder="{{placeHolder}}" placeholderClass="search-input-placeholder"
value="{{searchKey}}" wx:if="{{inputEnable}}"></input>
<view class="search-input" wx:else>{{placeHolder}}</view>
<image bindtap="onClear" class="close-btn" src="/close.svg" wx:if="{{searchKey}}"></image>
</view>
js
data: {
placeHolder: '输入关键词...',
autoFocus: false,
inputEnable: true
},
onConfirm: function (e) {
let s = e.detail.value;
wx.navigateTo({
url: '/pages/list/list?key=' + s,
})
}
onInput: function (e) {
this.setData({
searchKey: e.detail.value
})
},
onClear: function () {
this.setData({
searchKey: '',
})
},
接收页面
onLoad: function (options) {
console.log(options)
let id = options.id;
console.log(options.id)
this.setData({
id: id
}),
this.goDetails()
},
goDetails() {
let url = "https://api.tbk.dingdanxia.com/tbk/id_privilege/?id=" + this.data.id + "&itemInfo=false&apikey=N2E9BjwSiA9CE3da60hxhHRnsgUKEkGP"
wx.request({
url: url,
header: {
"Content-Type": "appLication/json"
},
success: res => {
this.setData({
dataList: res.data.data,
// detailed: res.data.data.itemInfo.small_images.string
});
}
})
},