Blame view

examples/routers/form.vue 1.51 KB
9f5e2c7e   梁灏   update Form
1
  <template>
ef090131   梁灏   optimize Input va...
2
      <div style="width: 300px;">
05e2dda0   梁灏   fixed #768
3
4
          <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
              <Form-item label="爱好" prop="interest">
841cb1fe   Aresn   Menu support tran...
5
                  <Input v-model="formValidate.interest" number></Input>
fc0c4c78   梁灏   fixed #494
6
7
              </Form-item>
              <Form-item>
05e2dda0   梁灏   fixed #768
8
9
                  <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                  <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
fc0c4c78   梁灏   fixed #494
10
              </Form-item>
05e2dda0   梁灏   fixed #768
11
          </i-form>
fc0c4c78   梁灏   fixed #494
12
      </div>
9f5e2c7e   梁灏   update Form
13
14
15
  </template>
  <script>
      export default {
9f5e2c7e   梁灏   update Form
16
          data () {
184dba1c   梁灏   update Form
17
              return {
05e2dda0   梁灏   fixed #768
18
                  formValidate: {
841cb1fe   Aresn   Menu support tran...
19
                      interest: ''
c3a9f389   梁灏   update Input
20
                  },
05e2dda0   梁灏   fixed #768
21
22
                  ruleValidate: {
                      interest: [
841cb1fe   Aresn   Menu support tran...
23
24
25
26
27
                          {
                              required: true,
                              type: 'number',
                              trigger: 'change'
                          }
257f80f1   梁灏   support Form
28
                      ]
184dba1c   梁灏   update Form
29
30
                  }
              }
9f5e2c7e   梁灏   update Form
31
          },
184dba1c   梁灏   update Form
32
          methods: {
ef090131   梁灏   optimize Input va...
33
34
35
36
37
38
39
40
41
42
43
              handleSubmit (name) {
                  this.$refs[name].validate((valid) => {
                      if (valid) {
                          this.$Message.success('提交成功!');
                      } else {
                          this.$Message.error('表单验证失败!');
                      }
                  })
              },
              handleReset (name) {
                  this.$refs[name].resetFields();
fc0c4c78   梁灏   fixed #494
44
              }
184dba1c   梁灏   update Form
45
          }
8bca1070   梁灏   update Input on-f...
46
      }
ef090131   梁灏   optimize Input va...
47
  </script>