搜索框

231 阅读1分钟

wxml

<!--pages/search/search.wxml-->
<van-search
  value="{{ value }}"
  placeholder="请输入搜索关键词"
  show-action
  input-align="center"
  bind:search="onSearch"
  bind:cancel="onCancel"
  bind:change="onChange"
/>
<listItem></listItem>

js

const { goodsHttp } = require('../../http/api')
Page({
  onLoad: function () {
    this.init()
  },
  async init() {
    try {
      let res = await goodsHttp({})
      console.log(res)
    }catch (err) {
      console.log(err);
    }
  },
  /**
   * 页面的初始数据
   */
  data: {
    value: ''
  },

  onChange(e) {
    this.setData({
      value: e.value
    })

  },
  onSearch() {},
  onCancle() {},
  /**
   * 生命周期函数--监听页面加载
   */
})