<!-- 子组件 -->
<template>
<div>
<h3>年龄{{ myAge }}</h3>
<button @click="onClick">尝试修改props内容</button>
</div>
</template>
<script>
export default {
props: ["age"],
data() {
return {
myAge: this.age,
};
},
methods: {
onClick() {
this.myAge++;
},
},
};
</script>