(vue)el-steps从别的页面跳转进来怎么实现和点击同样效果
(vue)el-steps从别的页面跳转进来怎么实现和点击同样效果
需求:
解决思路:监听路由,给active赋值对应下标
组件:
<el-steps:active="active"finish-status="process"class="steps custom-steps":align-center="true"
><el-stepv-for="(item, index) in StepsList.list":key="item.title":title="item.title":class="[index == active ? 'active-step' : '',index < active ? 'finish-step' : '',]"><template #icon><img:src="active == index? item.selectedIcon: active < index? item.noSelectedIcon: item.pastIcon"alt=""style="width: 60px; height: 60px"@click="selectStep(index)"></template></el-step>
</el-steps>
监听:
watch: {'$route'(to, from) {console.log('Route change', to.path)if (to.path === '/Steps/ParameterRecommendation') {this.active = 3}}},