element-ui 控制输入框只可以输入数字 青旅半醒 2023-02-19 04:27 1阅读 0赞 <el-input :readonly="!isWrite" v-model="days" must='天数' oninput="value=value.replace(/[^\d]/g,'')" ></el-input> <el-input @keyup.enter.native="search(1)" v-model="searchValue[value.prop2]" onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"> </el-input> 其中`oninput`和`onkeyup`属性是控制只可以输入数字的。 [参考文档:https://juejin.im/post/5ce77ebcf265da1b9612de0a][https_juejin.im_post_5ce77ebcf265da1b9612de0a] [https_juejin.im_post_5ce77ebcf265da1b9612de0a]: https://juejin.im/post/5ce77ebcf265da1b9612de0a
还没有评论,来说两句吧...