收藏
回答

点击input,focus=true无效

框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 Bug input 微信iOS客户端 Android 6.6.7 6.6.7.1321

<!--index.wxml-->

<view class="container">

  <view class="section i-item {{focus1}}">

    <input placeholder="点击的时候聚焦" value='123123' data-value='123123' data-name="focus1" focus="{{focus1}}" selection-start="{{SStart1}}" selection-end="{{SEnd1}}" bindtap="BindInputFocus" bindfocus='BindFocusInput' bindblur='InputBlur'/>

  </view>

  <view class="section i-item">

    <input placeholder="点击的时候聚焦"value='456456' data-value='456456' data-name="focus2" focus="{{focus2}}" selection-start="{{SStart1}}" selection-end="{{SEnd1}}" bindtap="BindInputFocus"bindfocus='BindFocusInput'bindblur='InputBlur'/>

  </view>

    <view class="section i-item">

    <input placeholder="点击的时候聚焦" value='789789' data-value='789789' data-name="focus3" focus="{{focus3}}" selection-start="{{SStart1}}" selection-end="{{SEnd1}}" bindtap="BindInputFocus"bindfocus='BindFocusInput'bindblur='InputBlur'/>

  </view>

  <view class="section i-item">

    <input placeholder="点击的时候聚焦"value='321321' data-value='321321' data-name="focus4" focus="{{focus4}}"  selection-start="{{SStart1}}" selection-end="{{SEnd1}}" bindtap="BindInputFocus" bindfocus='BindFocusInput'bindblur='InputBlur'/>

  </view>

    <view class="section i-item">

    <input placeholder="点击的时候聚焦" value='654654' data-value='654654'data-name="focus5" focus="{{focus5}}"  selection-start="{{SStart1}}" selection-end="{{SEnd1}}" bindtap="BindInputFocus"bindfocus='BindFocusInput'bindblur='InputBlur'/>

  </view>

  <view class="section i-item">

    <input placeholder="点击的时候聚焦"value='987987' data-value='987987'  data-name="focus6" focus="{{focus6}}"  selection-start="{{SStart1}}" selection-end="{{SEnd1}}" bindtap="BindInputFocus"bindfocus='BindFocusInput'bindblur='InputBlur'/>

  </view>

</view>

//index.js

//获取应用实例

const app = getApp()

Page({


  data: {

    focus1: false,

    focus2: false,

    focus3: false,

    focus4: false,

    focus5: false,

    focus6: false,

    SEnd1:0,

    SStart1:0


  },

  //事件处理函数

  onLoad: function () {   

    this.data.focus1 = false;

    this.data.focus2 = false;

    this.data.focus3 = false;

    this.data.focus4 = false;

    this.data.focus5 = false;

    this.data.focus6 = false;

    this.data.SEnd1=0;

    this.data.SStart1=0;

   console.log("focus:", this.data.focus1, this.data.focus2, this.data.focus3, this.data.focus4, this.data.focus5, this.data.focus6);

   this.setData({

     focus1: this.data.focus1,

     focus2: this.data.focus2,

     focus3: this.data.focus3,

     focus4: this.data.focus4,

     focus5: this.data.focus5,

     focus6: this.data.focus6,

     SEnd1: this.data.SEnd1,

     SStart1: this.data.SStart1

   })

  },

  BindInputFocus: function (e) {

    let name = e.currentTarget.dataset.name;

    this.data.focus1 = false;

    this.data.focus2 = false;

    this.data.focus3 = false;

    this.data.focus4 = false;

    this.data.focus5 = false;

    this.data.focus6 = false;

    this.data.SEnd1=0;

    this.data.SStart1=0;

    console.log("name:",name)

    this.data.SEnd1 = 6;

    console.log(" e.currentTarget.dataset.value", e.currentTarget.dataset.value, this.data.SEnd1, this.data.SStart1)

    this.setData({

      SEnd1: this.data.SEnd1,

      SStart1: this.data.SStart1

    })


    if (name =="focus1")

      this.setData({ focus1: true })


    if (name == "focus2")

      this.setData({ focus2: true })


    if (name == "focus3")

      this.setData({ focus3: true })


    if (name == "focus4")

      this.setData({ focus4: true })


    if (name == "focus5")

      this.setData({ focus5: true })


    if (name == "focus6")

      this.setData({ focus6: true })



    console.log("focus:", this.data.focus1, this.data.focus2, this.data.focus3, this.data.focus4, this.data.focus5, this.data.focus6);

  },


  InputBlur: function (e) {

    console.log("InputBlurInputBlurInputBlur------start")

    console.log("InputBlur:", this.data.focus1, this.data.focus2, this.data.focus3, this.data.focus4, this.data.focus5, this.data.focus6);


    console.log("InputBlurInputBlurInputBlur------End")

  },

  BindFocusInput: function (e) {

    console.log("BindFocusInputBindFocusInput------start")

    console.log("BindFocusInput:", this.data.focus1, this.data.focus2, this.data.focus3, this.data.focus4, this.data.focus5, this.data.focus6);

    console.log("BindFocusInputBindFocusInput------End")

  }

})


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

1 个回答

登录 后发表内容