uniapp 小程序 easyinput 组件 动态显示输入的字数和限制的字数

效果图

html部分

<view class="xiangdui">
			<uni-easyinput type="textarea" v-model="miaoshu" @input="inputChange" maxlength="100" placeholder="写段话描述下吧"></uni-easyinput>
			<view class="juedui">{
   
   { inputValueLength ? inputValueLength : 0  }}/100 </view>
</view>

js部分

<script>
	export default {
		data() {
			return {
				miaoshu:'',
				inputValueLength:'',
			}
		},
		onLoad( option ) {
		},
		onHide() {
		},
		onUnload() {
		},
		methods: {
			inputChange(e) {
				this.inputValueLength = parseInt(e.length);
				console.log('输入的内容',this.inputValueLength)
			}
		}
	}
</script>

style部分

<style>
.xiangdui {
    position: relative;
}
.juedui {
    position: absolute;
    right: 10px;
    bottom: 0;
    color: #646464;
}
</style>

猜你喜欢

转载自blog.csdn.net/weixin_60404020/article/details/139262629