請問vue元件如何reload或者說vue router如何重新整理當前的route??

時間 2021-05-12 02:52:05

1樓:呂小鳴

即使是相同路由之間的跳轉,也會重新重新整理頁面。

2樓:墨涵小雨

在main.js 裡面引入

import * as lodash from 'lodash'

/* 全域性lodash */

Vue.prototype.$baseLodash = lodash/* 全域性事件匯流排 */

Vue.prototype.$baseEventBus = new Vue()

在事件中執行

async refersh() ,

在路由頁面定義乙個布林值Boolean -- routerViewcreated() {

this.$baseEventBus.$on("reload-routerview", () =>this.routerView = false

this.$nextTick(() =>this.routerView = true還有乙個辦法用用provide / inject 組合;

3樓:加油呀

在data () );

this.$router.go(0);

return

}this.$router.replace下面直接寫this.$router.go(0);

我自己嘗試可以

4樓:陳勾丸

//跳轉到當前頁面需手動重新整理

if(router.history.current.fullPath === '/projects-reviewing/index') })

}else

watch:},

5樓:

@伯約感謝你的回答讓我在眾多回覆裡找到乙個簡單粗暴且有效的解決方法。

6樓:

export default

...this.reload()

更新再補充一下,其實基於上述原理,你可以封裝乙個 reload 元件,然後其他元件通過 Mixins 的方式再引入它,這樣就可以很方便地支援任意元件級別的 reload 了

7樓:

最近遇到了這個問題,我的寫法:

methods:,

watch:

不動路由,應該能滿足題中需求。

8樓:

參考下這個issue

[Feature] A reload method like location.reload() · Issue #296 · vuejs/vue-router

9樓:

已找到方法

router.go(0)

這個router是定義的vue-router,例如:

const router = new Router({})把這個export匯出,在需要的元件裡import引用

10樓:guo qian

我遇到的問題是部署到IIS上,Refresh 就是404了,因為請求傳送給了IIS,IIS按照請求路徑去查詢找不到指定檔案。

Vue元件建立的export default 和 Vue extend寫法區別,以及優劣?

第一點,Vue.component component name 等同於 Vue.component component name Vue.extend 也就是說,在使用Vue.component時候,使用不使用Vue.extend都可以。參見官方文件 Vue.js 第二點,Vue.componen...

Vue3 0下,如何在元件的setup 中監聽vuex裡某個state的變化?

幹槑 use this file at setup functionimport from vue import from store import from vue router import from lodash es Auth Guard 攔截 export default function...

為什麼 Vue3 的元件庫都在使用 jsx tsx?

我們來倒推原因。作為第三方庫 考慮的是相容可能的場景 需要很多動態化處理jsx就是js的擴充套件,比template靈活 未必都是jsx,但是是有傾向 官方推薦template是有道理的,畢竟針對template有靜態優化。所以這個考量的點在於,需不需要那麼多的動態化處理。 okay哦開 因為越基礎...