亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue 2.0 router每次切換頁面都會重載

vue 2.0 router每次切換頁面都會重載

慕碼人8056858 2018-10-12 14:15:07
router/index.jsimport Vue from 'vue'import VueRouter from 'vue-router'Vue.use(VueRouter)const route = new VueRouter({  routes:[     {      path:'/song/list',component: require('../views/song_list')     },{      path:'/singer/list',component: require('../views/singer_list')     },{      path:'/custom/list',component: require('../views/custom_list')     },{      path:'*',redirect:'/song/list'     }   ] })export default route;頭部導航this.$router.push({path:this.headTabs[index].path})子頁面每次都會重載(打印'song_list加載了')created (){      console.log('song_list加載了')      this.reqSongList();       var mySwiper = new Swiper('.swiper-container', {        direction: 'horizontal',         loop: true,        autoplay : 3000,        pagination: '.swiper-pagination'       });     }看別人的例子都是加載一次后,再次切換時都是直接顯示了(沒有加動態參數),沒有重載(觸發created)
查看完整描述

1 回答

?
慕運維8079593

TA貢獻1876條經驗 獲得超5個贊

請使用keep-alive


查看完整回答
反對 回復 2018-11-03
  • 1 回答
  • 0 關注
  • 522 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號