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:
GU Yiling 2018-07-20 23:26:03 +08:00 committed by Clark Du
parent b0d2f674c8
commit b5f6ed1332

View File

@ -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'