父组件
数据
data() { return { //已经选择的题目id集合 selectQuestionIdArrayList: [], }
子组件
components: { QuestionForTestPaper },
将数据绑定给子组件
<QuestionForTestPaper v-bind:selectQuestionIdArrayList="selectQuestionIdArrayList" ></QuestionForTestPaper>
子组件取用数据
export default { name: 'index', props: ['selectQuestionIdArrayList'], //监听数据变化 watch: { selectQuestionIdArrayList: function(newVal, oldVal) { //将数据赋值给子组件的变量 this.selectQuestionIdList = newVal console.log('this.selectQuestionIdList>>' + this.selectQuestionIdList) } }, …… }