el-input只能输入数字验证

  1. 输入正整数
	directives指令,只能输入数字,
	
	directives: {
		numberOnly: {
		  bind: function(el) {
			el.handler = function() {
			  el.value = Number(el.value.replace(/\D+/, ''))
			  console.dir(el.value)
			}
			el.addEventListener('input', el.handler)
		  },
		  unbind: function(el) {
			el.removeEventListener('input', el.handler)
		  }
		}
	},
  1. 只能输入大于1的数字

input.config-size( v-model="scope.row.value" placeholder="请输入配置大小" @keyup="handelNum(scope.row)")

				
	handelNum(obj) {
     	 if(obj.value == 0) {
				obj.value = '';
		  }else {
			  obj.value = obj.value.replace(/\D/g, '');
		  }
    },

你可能感兴趣的:(VUE,js)