当前位置:网站首页>【微信小程序】文本域输入带最大字数限制(1/100)
【微信小程序】文本域输入带最大字数限制(1/100)
2022-07-20 04:35:00 【常安cc】
<!-- 输入框 -->
<view class="inputBox">
<textarea class="textarea2" auto-height minlength="{
{minAddr}}" maxlength="{
{maxAddr}}" placeholder="请输入邮寄地址" placeholder-class="phcolor" bindinput="inputeditAddr" data-obj="contentAddr" value="{
{contentAddr}}">
<text class="currentWordNumber">{
{currentWordNumberAddr|0}}/{
{maxAddr}}</text>
</textarea>
</view>
// 文本域
minAddr: 0,
maxAddr: 100,
contentAddr: '', //邮寄地址
// inputeditAddr
inputeditAddr(e) {
var value = e.detail.value;
let dataset = e.currentTarget.dataset;
this.data[dataset.obj] = value;
var len = parseInt(value.length);
if (len > this.data.maxAddr) return;
this.setData({
currentWordNumberAddr: len
});
if (this.data.currentWordNumberAddr == 100) {
wx.showModal({
title: '提示',
content: '您输入的次数已达上限',
})
}
},
/* */
.inputBox {
width: 100%;
/* height: 76rpx; */
display: flex;
box-sizing: border-box;
/* padding: 0 20rpx; */
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
}
.textarea2 {
width: 100%;
min-height: 200rpx;
max-height: 400rpx;
line-height: 40rpx;
background-color: #f6f6f6;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
/* padding: 20rpx 0; */
padding: 20rpx;
box-sizing: border-box;
/* line-height: 60rpx; */
color: #2B2B36;
position: relative;
}
.currentWordNumber {
position: absolute;
bottom: 24rpx;
right: 26rpx;
color: #888;
}
边栏推荐
- Per job submission process of Apache Flink
- How do independent website sellers use Facebook homepage for social media marketing?
- What should virtual host agents pay attention to?
- To get to the bottom: Principle Analysis of Objective-C correlation attribute
- apple 为什么要改 objc
- Why should Apple change objc
- Qinghai VR fire simulation drill system meets the training needs of many people and scenes
- 一文详解|Go 分布式链路追踪实现原理
- AI2 (APP inventor 2) offline version
- 怎么批量删除Excel电子表格中不同的文字?
猜你喜欢
Developers must read: 2022 mobile application operation growth insight white paper
Kingdee's "answer sheet" forecast in the first half of the year: key customer strategy continued to break through, and arr increased by more than 45% year-on-year
记录uni-app 打包成apk后获取定位
vivo官网APP全机型UI适配方案
Difi: a go as you pay Wi Fi access system intensive reading notes (II)
Virtual reality coexists, building a digital intelligence life | HMS core Sparkle application innovation sub forum registration launch
Swift used smamb2 package, and the sad process of repacking
Excel打印技巧 十二种Excel打印技巧汇总
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
Detailed decision tree and random forest
随机推荐
爱学啊的博客-人生苦短,只做好课!
电路板调试
全栈代码测试覆盖率及用例发现系统的建设和实践
HMS core graphics and image technology shows the latest functions and application scenarios, and accelerates the construction of digital intelligence life
Huawei's general card identification function enables multiple card bindings with one key
得物客服一站式工作台卡顿优化之路
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
Capacity scheduling absolute value configuration queue usage and pit avoidance
国外域名能注册吗?
织梦添加栏目修改栏目时提示“保存目录数据时失败,请检查你的输入资料是否存在问题”
不掌握这些坑,你敢用BigDecimal吗?
Jenkins Automated Deployment
Check whether the date is between the other two dates
I summarize some experience of the whole R & D process
Introduction, installation and basic use of mongodb database
What is the registration process of website domain name?
Excel宏是什么?Excel宏的使用教程
Functions and advantages of interactive design of AR digital exhibition hall
Per job submission process of Apache Flink
Record the uni app and package it into APK to get the location