-
-
Notifications
You must be signed in to change notification settings - Fork 5k
[next] beforeRouteEnter : vm is undefined inside promise #648
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
Comments
beforeRouteEnter(route, redirect, next) {
superagent // remove return
.get(PATH_API + PATH_PROJECTS)
.end((err, res) => {
next((vm) => {
console.log(vm);
});
});
} |
Hi @fnlctrl It doesn't, I already try this. Regards |
You didn't provide a repro as the issue reporting guideline required. |
If you need me to provide repro just ask me then and I will be delighted to do so. |
The Issue Guidelines that appear when you open an issue clearly state that we want/need a reproduction. Please understand that if we leave open every issue that has no reproduction and doesn't appear to be a bug from the information that was provided (event hough yours may indeed be a bug), the issue list would get very crowded. We close those issues to keep the list manageable - yet we don't lock those issues, so the authors can provide further info that may warrant a reopening of the issue - like it happened here. |
I'm having a similar with vue-resource in beforeRouteEnter.
The HTTP request is sent, and the code in the response block is executed. next() is executed, because it does load the page. Taking it out keeps the page from loading. But nothing in the next callback is executed. The console log is never shown. If I put I apologize for the lack of repro, I'm crunching at work right now, but I thought I'd post anyway. I'll be back later with a repro if necessary. |
Hey @mattjneuber, Try to upgrade vue to 2.0-rc.5 and give me a shoot if it works |
↑The example is working fine. (note: Vue's version doesn't matter, it works with all vue 2.0-rc versions.) So I'm closing this issue as there wasn't a bug. Please make sure to read the guideline before submitting an issue. |
I have this problem too. Versions{
"vue": "2.0.0-rc.8",
"vue-resource": "1.0.3",
"vue-router": "^2.0.0-rc.7"
} Repohttps://github.com/erguotou520/dashboard Step to reproduce
P.S.While reload the page, the |
@erguotou520 could you kindly link to the source of a component with a beforeRoutEnter hook that shows this problem? Your project is quite big for a reproduction ... |
I start a demo project from |
I can confirm this bug exists. // workaround for current vue-router bug
// that calls activate before the component is created
let $self: Hello|null = null
// the arg of this function is undefined when called
function activate(self: Hello) { if ($self || ($self = self)) Hello.activate($self) }
export default component({
mounted(this: Hello) { if ($self === undefined) { Hello.activate($self = this) } },
template: `
<div>
<h3 @click="append('!')">{{ msg }}</h3>
</div>
`
}, Hello, activate/*, Hello.deactivate*/) That activate function is called by a helper function: function createFnActivateV2(fnActivate: (vm) => any): (route, redirect, next) => any {
return function (route, redirect, next) {
return next(fnActivate)
}
} |
@dyu Then please provide a repro |
The |
@LinusBorg Yes I'm sure. That helper function will be assigned as a @fnlctrl https://github.com/vuets/vuets/tree/master/docs/vue2 (I linked the specific file on initial post). Just
with
So now without the workaround, run the demo and click the nav links. |
@dyu A |
It can be reproduce when change the routes settings to children routes. Step npm i
npm run dev
# open localhost:8082
Router settings{
routes: [{
path: '/',
component: (resolve) => {
require(['./components/CommonView.vue'], resolve)
},
children: [{
path: 'foo',
component: (resolve) => {
require(['./components/Foo.vue'], resolve)
}
}, {
path: 'bar',
component: (resolve) => {
require(['./components/Bar.vue'], resolve)
}
}]
}]
} |
This link does not work: https://github.com/erguotou520/dashboard I assume this is a private repo? I can't find a repo named "dashboard" oin the repo list of your profile, either. |
@LinusBorg Sorry for name changed. Here is the new https://github.com/erguotou520/t2cloud-vmware |
Resolved in |
Hi,
I'm experiencing a weird issue when using [email protected].
According to : release docs, I'm trying to fetch data with a random API (no matter witch API I use) but the
vm
callback isundefined
.In the other hand when I'm logging
vm
without using a request promise,vm
is defined.The text was updated successfully, but these errors were encountered: