<view class="itemBox">
<input type="text" :value="account" @blur="getAccount" @input="accountStatus($event, 'account')" placeholder="请输入手机">
</view>
<view class="itemBox mb0">
<input :password="true" :value="password" @blur="getPassword" @input="accountStatus($event, 'password')"
placeholder="请输入登录密码">
</view>

- 发布:2021-04-28 10:41
- 更新:2021-12-28 17:09
- 阅读:3902
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 3.1.11
手机系统: Android
手机系统版本号: Android 10
手机厂商: 华为
手机机型: 华为mate30Pro 5G
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
// 校验账号或电话是否为空
accountStatus(e, flag) {
console.log(e);
if(flag == 'account'){
let accountText = "";
setTimeout(() =>{this.getValue(flag,e.detail.value);}, 10);
// this.getValue(flag,e.detail.value);
if (e.detail.value) {
this.isAccount = true;
} else {
this.isAccount = false;
}
if (this.isAccount && this.isPassword) {
this.disabledLogin = false;
this.customStyle.backgroundColor = "#0883FD !important";
} else if (!this.isAccount || !this.isPassword) {
this.disabledLogin = true;
this.customStyle.backgroundColor = "rgba(8,131,253, 0.3) !important";
}
} else if(flag == 'password'){
let passwordText = "";
setTimeout(() =>{passwordText = e.detail.value}, 0);
this.getValue(flag,e.detail.value);
if (e.detail.value) {
this.isPassword = true;
} else {
this.isPassword = false;
}
if (this.isAccount && this.isPassword) {
this.disabledLogin = false;
this.customStyle.backgroundColor = "#0883FD !important";
} else if (!this.isAccount || !this.isPassword) {
this.disabledLogin = true;
this.customStyle.backgroundColor = "rgba(8,131,253, 0.3) !important";
}
}
},
// 校验账号或电话是否为空
accountStatus(e, flag) {
console.log(e);
if(flag == 'account'){
let accountText = "";
setTimeout(() =>{this.getValue(flag,e.detail.value);}, 10);
// this.getValue(flag,e.detail.value);
if (e.detail.value) {
this.isAccount = true;
} else {
this.isAccount = false;
}
if (this.isAccount && this.isPassword) {
this.disabledLogin = false;
this.customStyle.backgroundColor = "#0883FD !important";
} else if (!this.isAccount || !this.isPassword) {
this.disabledLogin = true;
this.customStyle.backgroundColor = "rgba(8,131,253, 0.3) !important";
}
} else if(flag == 'password'){
let passwordText = "";
setTimeout(() =>{passwordText = e.detail.value}, 0);
this.getValue(flag,e.detail.value);
if (e.detail.value) {
this.isPassword = true;
} else {
this.isPassword = false;
}
if (this.isAccount && this.isPassword) {
this.disabledLogin = false;
this.customStyle.backgroundColor = "#0883FD !important";
} else if (!this.isAccount || !this.isPassword) {
this.disabledLogin = true;
this.customStyle.backgroundColor = "rgba(8,131,253, 0.3) !important";
}
}
},
预期结果:
应该是输入什么内容就展示什么内容
应该是输入什么内容就展示什么内容
实际结果:
输入的内容不能及时更新,并且还有删除已输入的内容字段的情况
输入的内容不能及时更新,并且还有删除已输入的内容字段的情况
bug描述:
app项目 input在手机下输入赋值时不能及时更新输入的数据

木杉丶 - 你喜或悲,他也都在那里
这是这个组件就有问题,而且很久了习惯了,因为你在更新那个value值,删除也是在实时更新这个值就会跟不上视图的反应速度,删除速度很快的,所以这个更新这个值的时候太慢跟不上,就会有删除的幻影。反正我是直接定义两个值,去交互使用。
2***@qq.com (作者)
定义的两个值怎么交互使用?可以具体说下吗?
2021-04-28 15:01
木杉丶
回复 2***@qq.com: 比如:value="account" ,定义一个account2,你现在去执行修改@input执行的时候,其实在input 上改和删除都是把值传给account2,至于account是只用来刚进来的时候赋值上去而已,执行@input的时候不用重复去赋值给account这个值,不然就会出现缓慢的视图重复更新视觉,你要先弄清楚你的这个情况是怎样出现,我也不确定你是不是我说的这种情况。
2021-04-28 18:33
2***@qq.com (作者)
回复 木杉丶: 好的,谢谢您的答复,不过咱们可能就是一种情况,嘻嘻。
2021-04-29 11:43