为什么要使用vuex呢,这相当于小程序中有全局变量this.变量名,在一般情况下我们在父子船传值的时候
有如下结构
以下是传统的父子传值
子组件代码:
<div @click="father">{
{activeIndex}}</div>
在<script></script>
中的props中进行注册接受
export default {
name: 'right_list',
mixins: [],
components: {
},
props: {
activeIndex: {
type: Number,
default: 0,
}
},
}
父组件: