Blame view

test/routers/form.vue 1.65 KB
9f5e2c7e   梁灏   update Form
1
  <template>
38646a11   梁灏   fixed Form reset ...
2
3
4
      <i-form v-ref:form-validate :model="formValidate" :rules="ruleValidate" :label-width="100">
          <Form-item label="输入框" prop="input">
              <i-input :value.sync="formValidate.input" placeholder="请输入"></i-input>
8bca1070   梁灏   update Input on-f...
5
          </Form-item>
38646a11   梁灏   fixed Form reset ...
6
7
8
9
10
11
12
13
14
          <Form-item label="Ajax:" prop="ajax">
              <div slot="label">
                  <span>Ajax</span>
                  <Tooltip content="基于 axios">
                      <Icon type="ios-help" size="14" color="#3399ff"></Icon>
                  </Tooltip>
                  <span>:</span>
              </div>
              <Switch :checked.sync="formValidate.ajax"></Switch>
8bca1070   梁灏   update Input on-f...
15
16
          </Form-item>
          <Form-item>
38646a11   梁灏   fixed Form reset ...
17
18
              <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
              <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
8bca1070   梁灏   update Input on-f...
19
20
          </Form-item>
      </i-form>
9f5e2c7e   梁灏   update Form
21
22
23
  </template>
  <script>
      export default {
9f5e2c7e   梁灏   update Form
24
          data () {
184dba1c   梁灏   update Form
25
              return {
38646a11   梁灏   fixed Form reset ...
26
27
28
                  formValidate: {
                      input: '123',
                      ajax: true
c3a9f389   梁灏   update Input
29
                  },
38646a11   梁灏   fixed Form reset ...
30
31
                  ruleValidate: {
  
184dba1c   梁灏   update Form
32
33
                  }
              }
9f5e2c7e   梁灏   update Form
34
          },
184dba1c   梁灏   update Form
35
          methods: {
38646a11   梁灏   fixed Form reset ...
36
              handleSubmit (name) {
c3a9f389   梁灏   update Input
37
38
39
40
41
42
43
                  this.$refs[name].validate((valid) => {
                      if (valid) {
                          this.$Message.success('提交成功!');
                      } else {
                          this.$Message.error('表单验证失败!');
                      }
                  })
38646a11   梁灏   fixed Form reset ...
44
45
46
              },
              handleReset (name) {
                  this.$refs[name].resetFields();
184dba1c   梁灏   update Form
47
48
              }
          }
8bca1070   梁灏   update Input on-f...
49
50
      }
  </script>