输入框输入数字,且不能有小数点存在
生活随笔
收集整理的這篇文章主要介紹了
输入框输入数字,且不能有小数点存在
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
基于Vue項目進行設置
<template><comp v-if="update"></comp><button @click="reload()">刷新comp組件</button></template><script>import comp from '@/views/comp.vue'export default {name: 'parentComp',data() {return {update: true}},methods: {reload() {// 移除組件this.update = false// 在組件移除后,重新渲染組件// this.$nextTick可實現在DOM 狀態更新后,執行傳入的方法。this.$nextTick(() => {this.update = true})}}}</script>基于Vue項目的組件庫 Vux 進行設置
//Vux組件庫<x-inputv-if="update1"v-model="numWithType1"style="border: 1px solid #cccccc;margin: 5px 0 0 67%;width: 60px;height:7px;" ></x-input>return {update1: true, }watch: {numWithType1(newval, oldval) {//正則表達式var patrn = /^[0-9]*$/;//監聽數據的變化if (!patrn.test(newval)) {this.update1 = false;this.numWithType1 = oldval;this.$nextTick(() => {this.update1 = true;});return;}}, } 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的输入框输入数字,且不能有小数点存在的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: this.$router 的三种跳转页面
- 下一篇: qrcode.js 二维码生成器