收藏
回答

bindinput问题求解

input输入框输入时,联想出搜索数据,点击搜索数据的某一项,把值填入输入框中,出现点击之后出现 联想出来的数据第二次弹出

回答关注问题邀请回答
收藏

2 个回答

  • 禾店短剧系统
    禾店短剧系统
    2021-06-18

    输入框联想问题可以参考https://blog.csdn.net/qq_19396231/article/details/84723524

    2021-06-18
    有用 1
    回复
  • 睡前原谅一切
    睡前原谅一切
    2019-05-30

    点击后是否又请求了了联想的接口呢?

    2019-05-30
    有用
    回复 26
    • 2019-05-30

      没有请求  又弹出来的时候数据跟之前是一样的

      2019-05-30
      回复
    • 睡前原谅一切
      睡前原谅一切
      2019-05-30

      可以写个简单的代码片段么

      2019-05-30
      回复
    • 2019-05-30回复睡前原谅一切

      <view class='input_container border_radius margin_top30 border'>

      <text class='text' decode="{{true}}" space="{{true}}" style='color:{{color}}'>学校名称:</text>

      <input placeholder="请输入学校名称" auto-focus type='text' name='schoolName' bindblur='bindSchoolNameBlur' bindinput='bindSchoolNameInput' value='{{schoolName}}' />

      </view>

      <view class="school_info school_position" style='background:{{color}};height:{{schoolBoxHeight}}rpx;' hidden='{{isShowSchool == false}}'>

      <view wx:for="{{schoolList}}" wx:key="unique" hidden='{{isShowSchool == false}}' data-schoolname='{{item.schoolName}}' data-schoolid='{{item.schoolId}}' catchtap='switchSchoolName'>

      <text>

      {{item.cityName}} {{item.areaName}} {{item.schoolName}}</text>

      </view>

      </view>



      bindSchoolNameInput: function(e) {

      console.log(e);

      var that = this;

      params.url = "/user/school-list";

      params.schoolName = e.detail.value;

      app.request('/app-mini/port-forward', params).then(

      res => {

      if (res.ok) {

      that.setData({

      count: count + 1,

      schoolList: res.schoolList,

      isShowSchool: true,

      schoolBoxHeight: res.schoolList.length > 5 ? 500 : res.schoolList.length * 100,

      })

      } else {

      app.showToast(res.errorMsg);

      }

      }

      );

      },




      switchSchoolName: function(e) {

      this.onLoad(JSON.stringify({

      schoolId: e.currentTarget.dataset.schoolid,

      schoolName: e.currentTarget.dataset.schoolname,

      type: 'school'

      }))

      },


      onLoad: function(options) {

      console.log(options);

      if (JSON.stringify(options) != '{}') {

      if (JSON.parse(options).type == 'school') {

      this.setData({

      schoolId: JSON.parse(options).schoolId,

      schoolName: JSON.parse(options).schoolName,

      isShowSchool: false

      })

      } else if (JSON.parse(options).type == 'student') {

      this.setData({

      studentName: JSON.parse(options).studentName,

      studentId: JSON.parse(options).studentId,

      phone: JSON.parse(options).phone,

      isShowStudent: false

      })

      var that = this;

      params.url = "/user/relationship-list";

      params.stduentId = this.data.studentId

      app.request('/app-mini/port-forward', params).then(

      res => {

      console.log(res);

      if (res.ok) {

      that.setData({

      relationshipList: res.relationshipList,

      relationshipId: res.relationshipList[that.data.index].relationshipId

      })

      } else {

      app.showToast(res.errorMsg);

      }

      }

      );

      }

      }

      wx.setNavigationBarColor({

      frontColor: '#ffffff',

      backgroundColor: app.getDataFromStorage('themeColor'),

      })

      this.setData({

      color: app.getDataFromStorage('themeColor'),

      })

      },


      2019-05-30
      回复
    • 2019-05-30回复睡前原谅一切

      这是所有的代码




      2019-05-30
      回复
    • 睡前原谅一切
      睡前原谅一切
      2019-05-30回复

      麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

      2019-05-30
      回复
    查看更多(21)
登录 后发表内容