Blame view

test/routers/form.vue 2.03 KB
9f5e2c7e   梁灏   update Form
1
  <template>
184dba1c   梁灏   update Form
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
      <div style="width: 400px">
          <i-form v-ref:form :model="form" :rules="rules" :label-width="50" label-position="right">
              <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>
              <form-item>
                  <i-button type="primary" @click="onSubmit('form')">提交</i-button>
              </form-item>
9f5e2c7e   梁灏   update Form
17
18
19
20
21
22
23
          </i-form>
      </div>
  </template>
  <script>
      export default {
          props: {},
          data () {
184dba1c   梁灏   update Form
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
              return {
                  form: {
                      mail: '',
                      passwd: ''
                  },
                  rules: {
                      mail: [
                          {
                              required: true, message: '请输入邮箱', trigger: 'blur'
                          },
                          {
                              min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'
                          }
                      ],
                      passwd: [
                          {
                              required: true, message: '请输入密码', trigger: 'blur'
                          }
                      ]
                  }
              }
9f5e2c7e   梁灏   update Form
45
46
          },
          computed: {},
184dba1c   梁灏   update Form
47
48
49
50
51
52
53
54
55
56
57
58
          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
59
60
      };
  </script>