vue入门记录 二

1.Element-ui表单验证+提交

vue入门记录 二_第1张图片

 return {
                quer: {
                    querId: ''
                },
                rules: {
                    querId: [
                        {required: true, message: '请输入ID'},
                        {type: 'number', message: '必须是数字'}
                    ],
                },
                user: {
                    id: '',
                    name: '',
                    age: ''
                },
                tableData: [],
            }
//Methods
getUserList() {
                this.$refs.quer.validate((valid) => {
                    if (valid) {
                        this.tableData = [];
                        this.$ajax.get('/api/user/getUserInfo/' + this.quer.querId).then(response => {
                            console.log(response.data.body)
                            for (let i in response.data.body) {
                                this.tableData.push(response.data.body[i]);
                            }
                        }), err => {
                            console.log(err)
                        }
                    } else {
                        return false;
                    }
                });
            },

你可能感兴趣的:(Vue)