小程序 搜索跳转传值到结果页面

 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
                });
            }
        })
    },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值