记录~记录~~有时候,我们会遇到一个页面有两个页签切换需求,但是为了避免同时加载两个页面,我们要做到的就是当前进入的是那个页面,就先加载哪一个页面,并且也不会造成浏览器地址的变化。一开始我使用的方法是在当前页面再加个 <router-view/> 实现二级路由,功能也是可以实现的,但是当我不停的切换的时候,浏览器地址也会不断的改变,所以但我点击浏览器返回键的时候,就会出现一个不停的返回上一个页面,导致这两个页签不停切换,到最后才能回到首页。所以为了避免如此差的体验,最后结合mintUI实现理想的效果,废话不多说,具体实现如下:

<template>
<div class="votepage">
<div class="tab">
<mt-navbar v-model="selected">
<mt-tab-item id="1" @click.native="selectChange('VoteList')">投一票</mt-tab-item>
<mt-tab-item id="2" @click.native="selectChange('VoteResult')">看结果</mt-tab-item>
</mt-navbar>
</div>
<mt-tab-container v-model="selected">
<mt-tab-container-item :id="selected">
<component :is='currentView' keep-alive></component>
</mt-tab-container-item>
</mt-tab-container>
</div>
</template> <script>
import VoteList from '@/components/VoteList.vue'
import VoteResult from '@/components/VoteResult.vue'
export default {
name: 'votepage',
data(){
return{
selected:"1",
currentView:"VoteList",
}
},
mounted(){ },
methods:{
selectChange(view){
this.currentView = view
}
},
components:{
VoteList,
VoteResult
}
}
</script>

告诉自己,每天进步一点点并持之以恒~

最新文章

  1. iOS MJRefresh设置MJRefreshStateNoMoreData状态图片
  2. WinForm:DataGridView新增加行
  3. ListView到顶部不可再拉
  4. python之路-Day7
  5. POJ 1365 Prime Land(数论)
  6. 2015年12月01日 GitHub入门学习(二)手把手教你Git安装
  7. 在NopCommerce中启用MiniProfiler
  8. [iOS基础控件 - 6.11.4] storyboard 的 Segue
  9. FZU1862(线段树 或者 DP)
  10. 关于微信小程序的的总结
  11. docker的简单应用(总结笔记)
  12. 初探linux子系统集之led子系统(二)
  13. bzoj1061 建图 + 最小费用流
  14. yarn不是内部指令 react-native不是内部指令
  15. 学习笔记TF045:人工智能、深度学习、TensorFlow、比赛、公司
  16. 使用SqlSugar 4.X的T4生成实体类
  17. android studio 的基本使用和建立一个小项目
  18. 利用Percona monitoring for zabbix监控MySQL
  19. Spring的@Scheduled任务调度
  20. The type org.springframework.context.support.AbstractApplicationContext cannot be resolved

热门文章

  1. Tensorflow中multiply()函数与matmul()函数的用法区别
  2. 0003 配置完整的url访问路径
  3. 10.3.4参数绑定 bind
  4. 小匠第二周期打卡笔记-Task05
  5. 阿里云负载均衡-note
  6. 【Python】天天向上的力量
  7. Android 开发 微信分享,登陆,获取信息
  8. ts中的类
  9. Explainable ML
  10. 洛谷 1219:八皇后 (位运算 &amp; DFS)