Input box digital validation --vue, elementui

direct code

<template>
    <div>
        <el-form :model="formData" ref="formData" :rules="formRules">
            <el-row :gutter="20">
                <el-col :span="10">
                    <el-form-item label="数字验证框" prop="amt">
                        <el-input v-model.number="formData.amt"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
    </div>
</template>
<script>
export default {
    data(){
        return {
            formData: {
                amt: null
            },
            formRules: {
                amt: [ { required: true,message:'必填信息' }, { type:'number', message: '必须是数字' } ]
            }
        }
    }
}
</script>

important point

  • Form data binding, rule binding; form-item prop attribute binding
  • When the input is bound, use the number modifier by default to use Number for conversion
  • In the rule rule, only the attributes and prompt information of the judgment are written, and the trigger conditions are not written, for example, trigger:'blur' is not written.

inputnumber

  • input-numberThere are special tags in vue , which can also be used

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325202748&siteId=291194637