日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

input 限制輸入 小數點后兩位

作者:嘿,小蘋果 更新時間: 2022-05-06 編程語言
<u--input placeholder="輸入積分數量" type='number' inputAlign='right' border="none" clearable
						v-model="countnum" @change="change"  @input="inputNumber">u--input>
change(e) {	
 if(e){
		// 正則表達試
		e = (e.match(/^\d*(\.?\d{0,2})/g)[0]) || null
		// 重新賦值
		this.$nextTick(() => {
			   this.countnum = e
		});
	}
},

或者是

// 只能輸入兩位小數
	inputNumber(e) {
		//正則表達試
		 e = (e.match(/^\d*(\.?\d{0,2})/g)[0]) || null
		
		 //重新賦值給input
		 this.$nextTick(() => {
		    this.countnum = e
		 })
	},

原文鏈接:https://blog.csdn.net/AAAXiaoApple/article/details/122566112

欄目分類
最近更新