子组件
<template>
<view>
<button @click="onClick">{{ value }}</button>
</view>
</template>
<script>
export default {
name: '',
components: {},
props: {
value: {
type: Number,
default: 0,
},
},
model: {
prop: 'value',
event: 'change',
},
data() {
return {}
},
methods: {
onClick() {
let new_value = this.value + 1
this.$emit('change', new_value)
},
},
}
</script>
<style scoped lang="scss"></style>
父组件
<template>
<view>
<demo v-model="number"></demo>
<view>{{ number }}</view>
</view>
</template>
<script>
import demo from '../components/demo.vue'
export default {
name: '',
components: {
demo,
},
data() {
return {
number: 1,
}
},
methods: {},
}
</script>
<style scoped lang="scss"></style>
1 个回复
诸葛
正式版本此问题有没有得到官方解决?