原生的ajax 前端中数据交互fetch

jquery中的 $.ajax() $.get() $.post() $.load()
node.js: request get post
框架中
vue-resource --> vue 1.x 使用 Vue 2.x弃用 vue3.0
axios.js 第三方的一个库
相似度很高
学习: vue-resource
使用: axios

  1. 引入vue-resource后
  2. Vue.http.get()
  3. this.$http.get()
  4. 总结 Vue
  5. Vue.http.get()
  6. this.$http.get()
    返回的结果是一个promiseObj
    .then().then() 多个不同任务

建议写法: this.KaTeX parse error: Expected '}', got '#' at position 52: …new Vue({ el: '#̲app', data: { u…http.get(’./data/user.json’)
// let p = this.KaTeX parse error: Expected 'EOF', got '}' at position 395: ….log( error )) }̲, // 动态数据 前台 ——…http({
url: ‘http://localhost:8090/get.php’,
params: {
a: this.username,
b: this.password
}
}).then(
res => console.log( res )
).catch(
err => console.log( err )
)
},
postPhp(){
//post
this.KaTeX parse error: Expected 'EOF', got '}' at position 327: …e.log( err ) ) }̲, jsonp(){ //js…http.jsonp(url,[config]).then().catch()
this.$http.jsonp(‘https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su’,{
params: {
wd: ‘yyb’
},
jsonp: ‘cb’,
jsonpCallback: ‘aa’
}).then(
res => this.data = res.body
).catch( error => console.log( error ))
}
}
})

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值