1.去掉input在type="number"时的上下箭头
<style> input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{ -webkit-appearance:textfield; } input[type="number"]{ -moz-appearance:textfield; } </style>
2.禁用input数字滚轮事件
<input type="number" onmousewheel="stopScrollFun" onDOMMouseScroll="stopScrollFun"/> function stopScrollFun(evt) { evt = evt || window.event; if(evt.preventDefault) { // Firefox evt.preventDefault(); evt.stopPropagation(); } else { // IE evt.cancelBubble=true; evt.returnValue = false; } return false; }
3.使用element-ui+vue时,在el-input加上@mousewheel.native.prevent来阻止鼠标滚动
<el-input type="number" @mousewheel.native.prevent />
如果还需要禁止上下箭头,则可采用以下方式
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button{ -webkit-appearance: none !important; margin: 0; } input[type="number"]{-moz-appearance:textfield;}