- parent component code
<template>
<div>
<item1 :test="{test:1}"></item1>
</div>
</template>
- Sub-component Code
<template>
<div>
<input v-model="test.test">
</div>
</template>
<script>
export default {
props: {
test: Object
}
}
</script>
at this time, any modification in the input box of the child component will not report an error, because the value we pass through the parent component is compound type data, and it will report an error when we change to the data of normal type, as follows
the reason for reporting the error is that we modified the following
- parent component code
<template>
<div>
<item1 :test="1"></item1>
</div>
</template>
- Sub-component Code
<template>
<div>
<input v-model="test">
</div>
</template>
<script>
export default {
props: {
test: Number
}
}
</script>
can anyone explain it?