鍍金池/ 問答/Linux  HTML/ vue路由跳轉(zhuǎn)后,怎么把跳轉(zhuǎn)前的數(shù)據(jù)傳給跳轉(zhuǎn)后的組件

vue路由跳轉(zhuǎn)后,怎么把跳轉(zhuǎn)前的數(shù)據(jù)傳給跳轉(zhuǎn)后的組件

路由結(jié)構(gòu)如下,如何把index數(shù)據(jù)傳給datum
在不使用vuex的情況下
因?yàn)閿?shù)據(jù)非常長所以不適用路由傳參
第二個組件創(chuàng)建時第一個組件已經(jīng)銷毀,event bus無法使用
還有方法傳遞數(shù)據(jù)嗎?

routes: [
    {
      path: '/',
      name: 'index',
      component: index,
    },
    {
      path: '/datum',
      name: 'datum',
      component: datums
    }
    }
回答
編輯回答
她愚我

一般通過URL把model的ID傳給對應(yīng)頁面,然后在頁面里通過ID向后端重新請求model

2018年6月20日 08:23
編輯回答
旖襯

使用sessionStorage,存儲就可以了

2017年6月6日 11:57
編輯回答
青裙

如果要傳遞的數(shù)據(jù)具有相對廣泛的應(yīng)用價值,那么可以掛載到根組件上,所有組件都從根組件上取這段數(shù)據(jù);
如果只是一段臨時性的業(yè)務(wù)數(shù)據(jù),那么可以在跳轉(zhuǎn)路由前將數(shù)據(jù)存進(jìn)sessionStorage,供新組件取用。

2018年3月13日 12:05
編輯回答
失心人

放cookie,localStorage,sessionStorage里,區(qū)別可以看http://www.lixuejiang.me/2016...

2017年6月30日 10:50
編輯回答
尤禮
2018年3月14日 05:32