tags:’vue’categories: ‘vue’限制只能输入数字:使用v-number-only tags:’vue’ categories: ‘vue’ 限制只能输入数字:使用v-number-onlyVue.directive('numberOnly', { bind: function (el) { el.handler = function (e) { e.target.value = e.target.value.replace(/\D+/, ''); }; el.addEventListener('input', el.handler); }});