字节小程序
开发者社区
小程序小游戏
登录
from表单中input的标签,在未失去焦点的情况下Submit,会获取不到值

from表单中input的标签,在未失去焦点的情况下Submit,会获取不到值

843浏览作者: baixingjob
<form data-event-opts="{{[['submit',[['formSubmit',['$event']]]]]}}" bindsubmit="__e">
            <view class="subline input_one"><input type="text" name="mobile" placeholder="请输入手机号"
                    data-event-opts="{{[['input',[['__set_model',['','phone','$event',[]]]]]]}}" value="{{phone}}"
                    bindinput="__e" />
                <image src="../../static/image/close3.png" data-event-opts="{{[['tap',[['reset',['$event']]]]]}}"
                    bindtap="__e"></image>
            </view>
   
            <view class="subline input_one"><text data-event-opts="{{[['tap',[['focus',['plateNumber']]]]]}}"
                    style="font-size:32rpx;color:#666666;width:160rpx;line-height:100rpx;"
                    bindtap="__e">{{imgcode||"请输入"}}</text>
                <image style="{{'width:'+(width+'px')+';'+('height:'+(height+'px')+';')}}" src="{{imgcodePic}}"
                    data-event-opts="{{[['tap',[['makeMaptcha',['$event']]]]]}}" bindtap="__e"></image>
            </view>
       
            <view class="subline input_one"><input type="number" name="mobile_vcode" placeholder="请输入验证码" />
                <view class="getcode"><text data-event-opts="{{[['tap',[['getCode']]]]}}" hidden="{{!(show)}}"
                        style="color:#1787fb;margin-left:30rpx;" bindtap="__e">获取验证码</text><text hidden="{{!(!show)}}"
                        style="color:#e2e2e2;margin-left:30rpx;">{{"等待 "+count+" s"}}</text></view>
            </view>
            
            <navigator class="code" url="myLogin" hover-class="none">使用账号密码登录 ></navigator><button class="mysubmit"
                form-type="submit">立即登录</button>
            <view class="regjober"><text style="color:#999999;">没有账号?</text><text
                    data-event-opts="{{[['tap',[['nav',['$event']]]]]}}" bindtap="__e">立即注册</text></view>
        </form>

有这么一个表单,表单中有三个输入框,分别为手机号、图片验证码、短信验证码。


 formSubmit: function formSubmit(e) {
      console.log("手机号为:" + e.detail.value.mobile);
      console.log("图片证码为:" + e.detail.value.imgcode);
      console.log("手机验证码为:" + e.detail.value.mobile_vcode);
      this.verification(e);
      this.list_param = e.detail.value;
      if (this.is_code) {
        this.login();
      }
    },

在点击立即登陆的时候获取一下表单中的手机号,和短信验证码,

问题来了。

在输入完手机号,图片验证码之后,输入短信验证码,输入完短信验证码焦点在短信验证码的input标签上,此时点击立即登陆获取不到input标签的值,只有点击一下空白的地方,让每个标签都没有焦点的情况下才可以获取值

代码是使用uni-app 生成的,有些乱,

最后一次编辑于 2021年07月06日
加载中