84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
这个地方会报cannot read property push of undefined 。这个this好像指向的不是vue实例了。
在callMethod外面定义var _this=this因为在方法内部this指向的就变了。
下面再用:_this.$router.push('home/baby')
学习是最好的投资!
JS中的this是运行时确定的。
function f() { console.log(this); } var obj = {}; f(); // Window; f.apply(obj); // obj
回到问题: 由于complete是jsonp的回调函数,所以,他的运行时是这样调用的window.complete。 可以看jsonp请求的返回。所以咯,complete中的this是Window,并不是Vue。
complete
window.complete
JS中的this是运行时确定的。
回到问题:
由于
complete
是jsonp的回调函数,所以,他的运行时是这样调用的window.complete
。 可以看jsonp请求的返回。所以咯,complete
中的this是Window,并不是Vue。