欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          vue怎么實現(xiàn)A頁面跳轉到B頁面

          vue實現(xiàn)A頁面跳轉到B頁面的方法:1、設置A頁面,代碼如“”;2、將跳轉的url添加到$router中;3、設置B頁面,代碼如“created() {…}”;4、修改js內(nèi)容即可。

          vue怎么實現(xiàn)A頁面跳轉到B頁面

          本文操作環(huán)境:windows7系統(tǒng)、Vue2.9.6版,DELL G3電腦。

          vue怎么實現(xiàn)A頁面跳轉到B頁面?

          vue 從A界面跳轉到B界面并攜帶參數(shù)

          最近遇到一個需求,需要從A界面點擊一個按鈕跳轉到B界面,并且攜帶參數(shù)。

          我是這樣子實現(xiàn)了需求:

          A頁面:

          <el-button size="mini"                    type="success"                    @click="add"                    icon="el-icon-plus"                    round                    plain>{{$t('common.add')}}</el-button>         <el-button type="primary"                    size="mini"                    @click="edit"                    icon="el-icon-edit"                    plain                    round>{{ $t('common.edit') }}</el-button>

          點擊事件:

          add() {       this.lockTaskStatus = 'new'       this.toLockTaskManagePage()},edit() {       this.lockTaskStatus = 'edit'       this.toLockTaskManagePage()},toLockTaskManagePage() {       this.$router.push({         path: '/taskLockManage',         name: 'TaskLockManage',         params: {           status: this.lockTaskStatus        }       })}

          將將跳轉的url添加到 $router中。

          path 中的url 最前面加 / 代表是根目錄下,不加則表示是子路由。

          通過path + params的組合傳遞參數(shù)。

          B頁面:

          created() {     this.getParams()   },   watch: {     // 監(jiān)測路由變化,只要變化了就調(diào)用獲取路由參數(shù)方法將數(shù)據(jù)存儲本組件即可     $route: 'getParams'   },   methods: {     getParams() {       // 取到路由帶過來的參數(shù)       const res = this.$route.params.status       console.log('getParams', res)     }}

          最后,還需在router/index.js中注冊:

          {     path: '/taskLockManage',     component: Layout,     redirect: '/taskManage/index',     hidden: true,     children: [       {         path: 'taskLockManage',         component: () => import('@/views/taskManage/taskLockManage'),         name: 'TaskLockManage',         meta: { title: 'taskLockManage', icon: 'user', noCache: true }       }     ]}

          這樣,便可實現(xiàn)了跳轉。(PS:這是目前發(fā)現(xiàn)的比較好的方法,希望哪位大佬有更好的方法指導。)

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號