-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scrollBehavior - Syntax Error: Unexpected token #723
Comments
seems like can't reproduce issue on glitch ( with nuxt.js 0.10.7 ) https://glitch.com/edit/#!/whimsical-badge can you provide more detail ? or reproduce on glitch ? |
@ausir0726 Thanks for your help. I am using nuxt as middleware (express starter.) When starting the dev the error appear:
So the problem IMHO is how nuxt generate the router.js.
Thanks in advance, |
|
@zhouyu1993 the same error
|
Here is 0.10.7 template for custom <% if (router.scrollBehavior) { %>
const scrollBehavior = <%= serialize(router.scrollBehavior).replace('scrollBehavior(', 'function(') %>
<% } else { %> Testing against various types of function seems this bug happens only when a function is provided and works with arrow and object members. (https://runkit.com/pi0/591db24aff32a300123e931a) |
@pi0 in the meantime could I do anything about it or I just need to wait for the bug fix? And one more thing. Do you know why the scrolling to the anchor is not working? |
Currently you can use object syntax it should work as you are currently using :) router: {
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
}, About anchors it seems they should be possible with this commit on vue-router. Maybe we can use such syntax: <nuxt-link :to="{path:'/blog', hash:'middle'}">Blog</nuxt-link> Update Workaround not working :D I think we may add some additional work after |
@pi0 I tried object syntax already and it is not working. I think this is because babel translate it to normal function anyway. |
What about arrow function? |
The same |
@pi0 Unfortunetly scroll to anchor is not working too. The problem in in the router.app.$nextTick(function () {
var position = getScrollPosition();
var shouldScroll = behavior(to, from, isPop ? position : null);
if (!shouldScroll) {
return
}
var isObject = typeof shouldScroll === 'object';
if (isObject && typeof shouldScroll.selector === 'string') {
var el = document.querySelector(shouldScroll.selector); // <<<---------- THIS IS NULL |
What's your node version @awronski ? |
@atinux what is interesting build is working: but dev is not :( |
I have the same problem using the nuxt/express template. |
Also having this on the express template. Tried it on |
@dan-gamble @awronski @azorvk There is a solution as below:
And it's a general bug when define a function property for |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
"nuxt": "^0.10.7"
nuxt.config.js:
gives me:
Thanks for help,
The text was updated successfully, but these errors were encountered: