[new feature] Field: add input slot

This commit is contained in:
陈嘉涵
2019-06-06 10:47:32 +08:00
parent 384b2f4001
commit f898b61e44
7 changed files with 55 additions and 2 deletions

View File

@@ -82,15 +82,23 @@ export default sfc({
methods: {
focus() {
this.$refs.input && this.$refs.input.focus();
if (this.$refs.input) {
this.$refs.input.focus();
}
},
blur() {
this.$refs.input && this.$refs.input.blur();
if (this.$refs.input) {
this.$refs.input.blur();
}
},
// native maxlength not work when type = number
format(target = this.$refs.input) {
if (!target) {
return;
}
let { value } = target;
const { maxlength } = this.$attrs;
@@ -200,6 +208,16 @@ export default sfc({
},
renderInput() {
const inputSlot = this.slots('input');
if (inputSlot) {
return (
<div class={bem('control', this.inputAlign)}>
{inputSlot}
</div>
);
}
const inputProps = {
ref: 'input',
class: bem('control', this.inputAlign),