vue input box can only enter numbers

  Scheme 1: add custom instruction 
  custom written instructions:
     directives: {
        numberOnly: {
            bind (it) {
                el.handler = function () {
                    el.value = el.value.replace(/\D+/, '');
                };
                el.addEventListener('input', el.handler);
            },
            unbind(el) {
                el.removeEventListener('input', el.handler);
            }
        }
    },
  Components wording:
  <Model = the Input-V "row.Weight"  V-Number-only  placeholder = "Please enter the flow distribution" />

 

Guess you like

Origin www.cnblogs.com/ChineseLiao/p/11843879.html