Blame view

test/routers/form.vue 1.74 KB
9f5e2c7e   梁灏   update Form
1
  <template>
8bca1070   梁灏   update Input on-f...
2
3
4
5
6
7
      <i-form v-ref:form-inline :model="formInline" :rules="ruleInline" inline>
          <Form-item prop="user">
              <i-input type="text" :value.sync="formInline.user" placeholder="Username">
                  <Icon type="ios-person-outline" slot="prepend"></Icon>
              </i-input>
          </Form-item>
6986d055   梁灏   Form add show-mes...
8
          <Form-item prop="password" :show-message="false">
8bca1070   梁灏   update Input on-f...
9
10
11
12
13
14
15
16
              <i-input type="password" :value.sync="formInline.password" placeholder="Password">
                  <Icon type="ios-locked-outline" slot="prepend"></Icon>
              </i-input>
          </Form-item>
          <Form-item>
              <i-button type="primary" @click="handleSubmit('formInline')">登录</i-button>
          </Form-item>
      </i-form>
9f5e2c7e   梁灏   update Form
17
18
19
  </template>
  <script>
      export default {
9f5e2c7e   梁灏   update Form
20
          data () {
184dba1c   梁灏   update Form
21
              return {
8bca1070   梁灏   update Input on-f...
22
23
24
                  formInline: {
                      user: '',
                      password: ''
c3a9f389   梁灏   update Input
25
                  },
8bca1070   梁灏   update Input on-f...
26
27
28
                  ruleInline: {
                      user: [
                          { required: true, message: '请填写用户名', trigger: 'change' }
c3a9f389   梁灏   update Input
29
                      ],
8bca1070   梁灏   update Input on-f...
30
31
32
                      password: [
                          { required: true, message: '请填写密码', trigger: 'blur' },
                          { type: 'string', min: 6, message: '密码长度不能小于6位', trigger: 'change' }
c3a9f389   梁灏   update Input
33
                      ]
184dba1c   梁灏   update Form
34
35
                  }
              }
9f5e2c7e   梁灏   update Form
36
          },
184dba1c   梁灏   update Form
37
          methods: {
8bca1070   梁灏   update Input on-f...
38
              handleSubmit(name) {
c3a9f389   梁灏   update Input
39
40
41
42
43
44
45
                  this.$refs[name].validate((valid) => {
                      if (valid) {
                          this.$Message.success('提交成功!');
                      } else {
                          this.$Message.error('表单验证失败!');
                      }
                  })
184dba1c   梁灏   update Form
46
47
              }
          }
8bca1070   梁灏   update Input on-f...
48
49
      }
  </script>