收藏
回答

输入框获取不到值?

在登录页

wxml
<input placeholder="请输入密码" data-name="password"   password="{{isPassword}}" bindinput="handleInput"   bindblur="handleInput"  cursor-spacing="10"  id="password" />
<view class="login-btn" bindtap="handleLogin"  >登录</view>
js
handleInput(e) {
    const {name} = e.currentTarget.dataset;
    const value = e.detail.value || "";
    clearTimeout(this._inputTimer);
    this._inputTimer = setTimeout(() => {
        if (this.data[name] !== value) {
            this.setData({[name]: value});
        }
    }, 30);

},
handleLogin() {

    const password = this.data.password;

    if ( !password) {
        query.select('#password').fields({properties: ['value']}, res => {
            if (res.value) {
                this.setData({
                    password: res.value
                });
            }
        }).exec()
    }


都做到这个地步了 真机调试的时候还是有一定概率获取不到值 ,有没有啥好的方法

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

3 个回答

  • Passerby
    Passerby
    2025-10-24

    有input事件了为什么还需要blur 功能需要吗 试试clearTime后加个this.inputTimer = null


    2025-10-24
    有用
    回复
  • showms
    showms
    发表于小程序端
    2025-10-23

    input外层包一个form,然后提交按钮改成submit类型

    2025-10-23
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    2025-10-23
    有用
登录 后发表内容