当前位置:首页>正文

vue中怎么实现自己发送ajax vuejs的computed怎么修改data里面的值

2023-05-21 23:48:10 互联网 未知

vue中怎么实现自己发送ajax

Vue.js Ajax使用方法 https://www.apiref.com/vue-zh/vuejs-ajax.html,案例如下:
window.onload = function(){
var vm = new Vue({
el:#box,
data:{
msg:Hello World!,
},
methods:{
get:function(){
//发送get请求
this.$http.get(/try/ajax/ajax_info.txt).then(function(res){
document.write(res.body)
},function(){
console.log(请求失败处理)
})
}
}
})
}

vuejs的computed怎么修改data里面的值

代码三:
this._initExecSQLInfo(this.uid) 先重新初始化
this.execSQLInfo.push(_resObj) 改变data中的数据;
_initExecSQLInfo 就是调用初始化1中的代码;execSQLInfo是调用mutation中的函数:ADD_SQL_INFO:(state,uid,resObj)=>{
state[uid].data.push(resObj)
}

随便看看