input-cell.vue
794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<template>
<view>
<zui-cell class="input-cell" :title="title" :required="required">
<zui-input v-model="model" :disabled="disabled" :type="type" :placeholder="placeholder" clearable @clear="$emit('clear')" @blur="$emit('blur')"/>
<slot name="right"></slot>
</zui-cell>
<slot></slot>
</view>
</template>
<script>
export default {
name: 'InputCell',
props: {
title: String,
value: [String, Number],
required: Boolean,
disabled: Boolean,
type: String,
placeholder: {
type: String,
default: '请输入'
}
},
data() {
return {
model: this.value,
};
},
watch: {
value(val) {
this.model = val;
},
model(val) {
console.log(val);
this.$emit('input', val);
}
}
}
</script>