mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 14:41:25 +00:00
fix: inject scrollBehavior in a more tolerant way (#3560)
Currently we cannot define `scrollBehavior` like: ```js scrollBehavior () { // ← we can have space before the parenthesis // ... } ``` Fixed this by using a `RegExp` to be more tolerant.
This commit is contained in:
parent
b0d2f674c8
commit
b5f6ed1332
@ -35,7 +35,7 @@ const _routes = recursiveRoutes(router.routes, '\t\t', _components)
|
|||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
|
|
||||||
<% if (router.scrollBehavior) { %>
|
<% if (router.scrollBehavior) { %>
|
||||||
const scrollBehavior = <%= serialize(router.scrollBehavior).replace('scrollBehavior(', 'function(').replace('function function', 'function') %>
|
const scrollBehavior = <%= serialize(router.scrollBehavior).replace(/scrollBehavior\s*\(/, 'function(').replace('function function', 'function') %>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
if (process.client) {
|
if (process.client) {
|
||||||
window.history.scrollRestoration = 'manual'
|
window.history.scrollRestoration = 'manual'
|
||||||
|
Loading…
Reference in New Issue
Block a user