鍍金池/ 問答/HTML/ vue 頁面相互傳值

vue 頁面相互傳值

由于剛學(xué)習(xí)vue,很多地方在官網(wǎng)上面看的不是很明白
現(xiàn)有這樣一個需求:

當點擊button時,跳轉(zhuǎn)到另一個頁面,另一個頁面內(nèi)容為上個頁面的數(shù)據(jù)詳細信息



當前頁面已經(jīng)獲取到數(shù)據(jù),想把數(shù)據(jù)傳到另一個頁面

請問如何通過路由跳轉(zhuǎn)的方式來進行頁面之間的相互傳值
  planDetail(personid, plan, relation, productProperty) {
        let param = {
          personId: personid,
          productCode: plan
        };
        console.log("入?yún)?, param);
        this.$http.postBody("/1/111", param, result => {
          console.log(result);
          this.productDetail = result.body.rows;
          if (relation == "1") {
            this.detailTitle =
              productProperty == "1" ? "都市客從" : "方法 " + "吃的是草";
          } else {
            this.detailTitle =
              productProperty == "1" ? "的是" : "的的" + "的方式vs";
          }
          this.familyShow = true;
                          this.$router.push({name: 'employeeplan', query:param})

        });
回答
編輯回答
過客

PolarisJack說的沒錯。

        /* 父組件 */
        /** 
        * 在index.js中的router注冊后
        * {
        * path: '/....',
        * name: 'aaa',
        * component: AAA
        * } 
        */
        this.$router.push({
                name: 'aaa',
                params: {
                        nameYouWant: name1,
                        nameYouWant2: name2
                }
        })
        
        /* 子組件 */
        // 子組件此處是$route, 沒有r, 此處輸出name1
        let thingsWeGet = this.$route.params.nameYouWant
2017年5月4日 18:10
編輯回答
祈歡

query 和 params 需要在router里面做配置。

2018年7月2日 12:42