mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 11:54:02 +00:00
[new feature] Field: add input slot
This commit is contained in:
@@ -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),
|
||||
|
Reference in New Issue
Block a user