File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,28 @@ exports[`e2e routes > generates the routes 1`] = `
118
118
/* no children */
119
119
}
120
120
]
121
+
122
+ export function handleHotUpdate(_router) {
123
+ if (import .meta .hot ) {
124
+ import.meta.hot.data.router = _router
125
+ }
126
+ }
127
+
128
+ if (import.meta.hot) {
129
+ import .meta .hot .accept ((mod ) => {
130
+ const router = import .meta .hot .data .router
131
+ if (! router ) {
132
+ import .meta .hot .invalidate (' [unplugin-vue-router:HMR] Cannot replace the routes because there is no active router. Reloading.' )
133
+ return
134
+ }
135
+ router .clearRoutes ()
136
+ for (const route of mod .routes ) {
137
+ router .addRoute (route )
138
+ }
139
+ router .replace (' ' )
140
+ })
141
+ }
142
+
121
143
"
122
144
` ;
123
145
Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ if (import.meta.hot) {
197
197
import.meta.hot.accept((mod) => {
198
198
const router = import.meta.hot.data.router
199
199
if (!router) {
200
- console.error('❌ router not found ')
200
+ import.meta.hot.invalidate('[unplugin-vue- router:HMR] Cannot replace the routes because there is no active router. Reloading. ')
201
201
return
202
202
}
203
203
router.clearRoutes()
You can’t perform that action at this time.
0 commit comments