reject(){
let _self = this;
var _appInstArr =[];
_appInstArr.push(_self.appInstId);
$.ajax({
url : path + '/appManagement/appManagementAction!updateAppInstancesStatusByIds.action',
cache: false,
type : 'post',
data : {
appInstIds : _appInstArr.toString(),
expectStatus: 9
},
success : function(data) {
if(data == "success"){
_self.$router.push({path:"/proxyList"});
top.navigatorTop.removeLastBreadNode(false);
_self.$message({
showClose: true,
message: _self.$t('tips.rejectSuccess'),
type: 'success'
});
return;
}
else{
_self.$message({
showClose: true,
message: _self.$t('tips.rejectFailed'),
type: 'error'
});
}
},
error : function(err) {
_self.$message({
showClose: true,
message: _self.$t('tips.rejectFailed'),
type: 'error'
});
}
});
},
在 ajax 中,不要隨便用 this,而要用 _self
如果在 success 中,將 _self.$router.push({path:"/proxyList"});
變更爲 this.$router.push({path:"/proxyList"});
,將會報錯:
Uncaught TypeError: Cannot read property 'push' of undefined