mirror of https://github.com/ElemeFE/element
fix input test
parent
6e31e61516
commit
84517bb5d9
|
@ -512,8 +512,9 @@ Form component allows you to verify your data, helping you find and correct erro
|
||||||
|
|
||||||
### Custom validation rules
|
### Custom validation rules
|
||||||
|
|
||||||
:::demo This example shows how to customize your own validation rules to finish a two-factor password verification.
|
This example shows how to customize your own validation rules to finish a two-factor password verification. And you can you `status-feedback` to add validate status icon。
|
||||||
|
|
||||||
|
:::demo
|
||||||
```html
|
```html
|
||||||
<el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-width="120px" class="demo-ruleForm">
|
<el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-width="120px" class="demo-ruleForm">
|
||||||
<el-form-item label="Password" prop="pass">
|
<el-form-item label="Password" prop="pass">
|
||||||
|
|
|
@ -503,16 +503,18 @@
|
||||||
|
|
||||||
### 自定义校验规则
|
### 自定义校验规则
|
||||||
|
|
||||||
::: demo 这个例子中展示了如何使用自定义验证规则来完成密码的二次验证
|
这个例子中展示了如何使用自定义验证规则来完成密码的二次验证,并且你可以通过 `status-feedback` 来给输入框添加反馈图标。
|
||||||
|
|
||||||
|
::: demo
|
||||||
```html
|
```html
|
||||||
<el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
|
<el-form :model="ruleForm2" :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
|
||||||
<el-form-item label="密码" prop="pass">
|
<el-form-item status-feedback label="密码" prop="pass">
|
||||||
<el-input type="password" v-model="ruleForm2.pass" auto-complete="off"></el-input>
|
<el-input type="password" v-model="ruleForm2.pass" auto-complete="off"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="确认密码" prop="checkPass">
|
<el-form-item status-feedback label="确认密码" prop="checkPass">
|
||||||
<el-input type="password" v-model="ruleForm2.checkPass" auto-complete="off"></el-input>
|
<el-input type="password" v-model="ruleForm2.checkPass" auto-complete="off"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="年龄" prop="age">
|
<el-form-item status-feedback label="年龄" prop="age">
|
||||||
<el-input v-model.number="ruleForm2.age"></el-input>
|
<el-input v-model.number="ruleForm2.age"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="el-form-item" :class="{
|
<div class="el-form-item" :class="{
|
||||||
|
'el-form-item--feedback': statusFeedback,
|
||||||
'is-error': validateState === 'error',
|
'is-error': validateState === 'error',
|
||||||
'is-validating': validateState === 'validating',
|
'is-validating': validateState === 'validating',
|
||||||
'is-success': validateState === 'success',
|
'is-success': validateState === 'success',
|
||||||
|
@ -63,6 +64,7 @@
|
||||||
labelWidth: String,
|
labelWidth: String,
|
||||||
prop: String,
|
prop: String,
|
||||||
required: Boolean,
|
required: Boolean,
|
||||||
|
statusFeedback: Boolean,
|
||||||
rules: [Object, Array],
|
rules: [Object, Array],
|
||||||
error: String,
|
error: String,
|
||||||
validateStatus: String,
|
validateStatus: String,
|
||||||
|
|
|
@ -43,6 +43,10 @@
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& .el-input__validateIcon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
@include e(label) {
|
@include e(label) {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -80,7 +84,7 @@
|
||||||
@include when(error) {
|
@include when(error) {
|
||||||
& .el-input__inner,
|
& .el-input__inner,
|
||||||
& .el-textarea__inner {
|
& .el-textarea__inner {
|
||||||
&:focus {
|
&, &:focus {
|
||||||
border-color: $--color-danger;
|
border-color: $--color-danger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,4 +115,9 @@
|
||||||
color: $--color-success;
|
color: $--color-success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@include m(feedback) {
|
||||||
|
.el-input__validateIcon {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,30 +47,24 @@ describe('Input', () => {
|
||||||
expect(vm.$el.querySelector('input').getAttribute('disabled')).to.ok;
|
expect(vm.$el.querySelector('input').getAttribute('disabled')).to.ok;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('icon', () => {
|
it('suffixIcon', () => {
|
||||||
vm = createVue({
|
vm = createVue({
|
||||||
template: `
|
template: `
|
||||||
<el-input
|
<el-input suffix-icon="time"></el-input>
|
||||||
icon="time"
|
`
|
||||||
@click="handleIconClick"
|
|
||||||
>
|
|
||||||
</el-input>
|
|
||||||
`,
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
iconClicked: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleIconClick(ev) {
|
|
||||||
this.iconClicked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, true);
|
}, true);
|
||||||
var icon = vm.$el.querySelector('.el-input__icon');
|
var icon = vm.$el.querySelector('.el-input__icon');
|
||||||
icon.click();
|
expect(icon).to.be.exist;
|
||||||
expect(icon.classList.contains('el-icon-time')).to.true;
|
});
|
||||||
expect(vm.iconClicked).to.true;
|
|
||||||
|
it('prefixIcon', () => {
|
||||||
|
vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input prefix-icon="time"></el-input>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
var icon = vm.$el.querySelector('.el-input__icon');
|
||||||
|
expect(icon).to.be.exist;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('size', () => {
|
it('size', () => {
|
||||||
|
|
Loading…
Reference in New Issue