mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +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)
|
||||
|
||||
<% 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 { %>
|
||||
if (process.client) {
|
||||
window.history.scrollRestoration = 'manual'
|
||||
|
Loading…
Reference in New Issue
Block a user