Blame view

test/routers/form.vue 3.26 KB
9f5e2c7e   梁灏   update Form
1
  <template>
184dba1c   梁灏   update Form
2
      <div style="width: 400px">
578ca325   梁灏   fixed Radio bug
3
          <i-form v-ref:form :model="form" :rules="rules" :label-width="100" label-position="right">
184dba1c   梁灏   update Form
4
5
6
7
8
9
10
11
12
13
              <form-item label="邮箱" prop="mail">
                  <i-input :value.sync="form.mail" placeholder="请输入邮箱">
                      <Icon type="ios-email-outline" slot="prepend"></Icon>
                  </i-input>
              </form-item>
              <form-item label="密码" prop="passwd">
                  <i-input type="password" :value.sync="form.passwd" placeholder="请输入密码">
                      <Icon type="ios-locked-outline" slot="prepend"></Icon>
                  </i-input>
              </form-item>
578ca325   梁灏   fixed Radio bug
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
              <form-item label="radio" prop="single">
                  <radio :checked.sync="form.single">Single</radio>
              </form-item>
              <form-item label="radioGroup" prop="group">
                  <Radio-group :model.sync="form.group">
                      <Radio value="apple">
                          <Icon type="social-apple"></Icon>
                          <span>Apple</span>
                      </Radio>
                      <Radio value="android">
                          <Icon type="social-android"></Icon>
                          <span>Android</span>
                      </Radio>
                      <Radio value="windows">
                          <Icon type="social-windows"></Icon>
                          <span>Windows</span>
                      </Radio>
                  </Radio-group>
              </form-item>
184dba1c   梁灏   update Form
33
34
35
              <form-item>
                  <i-button type="primary" @click="onSubmit('form')">提交</i-button>
              </form-item>
9f5e2c7e   梁灏   update Form
36
37
38
39
40
41
42
          </i-form>
      </div>
  </template>
  <script>
      export default {
          props: {},
          data () {
184dba1c   梁灏   update Form
43
44
45
              return {
                  form: {
                      mail: '',
578ca325   梁灏   fixed Radio bug
46
47
48
                      passwd: '',
                      single: false,
                      group: ''
184dba1c   梁灏   update Form
49
50
51
52
                  },
                  rules: {
                      mail: [
                          {
578ca325   梁灏   fixed Radio bug
53
54
55
56
                              required: true, message: '请输入正确的邮箱', trigger: 'blur', type: 'email'
                          },
                          {
                              min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur'
184dba1c   梁灏   update Form
57
58
                          },
                          {
578ca325   梁灏   fixed Radio bug
59
                              min: 3, max: 50, message: '长度在 3 到 5 个字符', trigger: 'change'
184dba1c   梁灏   update Form
60
61
62
63
64
65
                          }
                      ],
                      passwd: [
                          {
                              required: true, message: '请输入密码', trigger: 'blur'
                          }
578ca325   梁灏   fixed Radio bug
66
67
68
69
70
                      ],
                      group: [
                          {
                              required: true, message: '请单选组'
                          }
184dba1c   梁灏   update Form
71
72
73
                      ]
                  }
              }
9f5e2c7e   梁灏   update Form
74
75
          },
          computed: {},
184dba1c   梁灏   update Form
76
77
78
79
80
81
82
83
84
85
86
87
          methods: {
              onSubmit (formName) {
                  this.$refs[formName].validate((valid) => {
                      if (valid) {
                          this.$Message.success('submit!');
                      } else {
                          this.$Message.error('error submit!');
                          return false;
                      }
                  });
              }
          }
9f5e2c7e   梁灏   update Form
88
89
      };
  </script>