Commit 84517bb5 authored by baiyaaaaa's avatar baiyaaaaa Committed by 杨奕

fix input test

parent 6e31e615
...@@ -512,8 +512,9 @@ Form component allows you to verify your data, helping you find and correct erro ...@@ -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 @@ ...@@ -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>
......
<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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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', () => { ...@@ -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" }, true);
> var icon = vm.$el.querySelector('.el-input__icon');
</el-input> expect(icon).to.be.exist;
`, });
data() {
return { it('prefixIcon', () => {
iconClicked: false vm = createVue({
}; template: `
}, <el-input prefix-icon="time"></el-input>
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('size', () => { it('size', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment