亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

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

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

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

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

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

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

    最近遇到一個需求,需要從A界面點擊一個按鈕跳轉(zhuǎn)到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        }       })}

    將將跳轉(zhuǎn)的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)了跳轉(zhuǎn)。(PS:這是目前發(fā)現(xiàn)的比較好的方法,希望哪位大佬有更好的方法指導(dǎo)。)

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