<template>
<div>
<input type="text" v-model="model">
</div>
</template>
<script>
export default {
props: {
value: {
type: String,
default: ''
}
},
computed: {
model: {
get() {
return this.value;
},
set(val) {
this.$emit('input', val);
}
}
}
}
</script>
应用组件
<template>
<div>
<easy-input v-model="easy"></easy-input>
{{easy}}
</div>
</template>
<script>
import EasyInput from './EasyInput'
export default {
components: {
EasyInput
},
data () {
return {
easy: ''
}
}
}
</script>
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!