我在 Vue.js 项目中使用 cleave.js 作为日期输入字段。
我通过的选项是这样的:
<cleave :options="{
date: true,
datePattern: ['m', 'd','Y']
}" id="date-input" placeholder="MM/DD/YYYY" type="text"></cleave>
如何设置 Y 的最大值?
最佳答案
我这样做是为了卡安全号码并且工作正常
const cardCCV = new Cleave("#cardCCV", {
numeral: true,
stripLeadingZeroes: false,
onValueChanged: function (e) {
const maxSize = 3;
if (e.target.rawValue.length > maxSize) {
cardCCV.setRawValue(e.target.rawValue.substring(0, maxSize));
}
},
});
关于javascript - 设置切割中的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48626493/