网络请求相关

request ajax axios
await asnyc promise
跨域

1vue-resource
vue将不再支持
参考https://blog.csdn.net/weixin_34401479/article/details/90155465

this.$http.get(url).then((res)=>{})
this.$http.get(url,{params : {a:1,b:2}}).then((res)=>{})

2axios
https://www.runoob.com/vue2/vuejs-ajax-axios.html
https://www.runoob.com/vue3/vue3-ajax-axios.html
axios.get()
axios.baseUrl

3
4
5
6jsonp
https://www.runoob.com/json/json-jsonp.html
以下代码会运行callbackFunction
页面会显示数据

<body>
<div id="divCustomers"></div>
<script type="text/javascript">
    //jsonp.php文件
/*  <?php
  header('Content-type: application/json');
  //获取回调函数名
  $jsoncallback = htmlspecialchars($_REQUEST ['jsoncallback']);
  //json数据
  $json_data = '["customername1","customername2"]';
  //输出jsonp格式的数据
  echo $jsoncallback . "(" . $json_data . ")";
      ?>*/
  function callbackFunction(result, methodName)
  {
    var html = '<ul>';
    for(var i = 0; i < result.length; i++)
    {
      html += '<li>' + result[i] + '</li>';
    }
    html += '</ul>';
    document.getElementById('divCustomers').innerHTML = html;
  }
</script>
<script type="text/javascript" src="https://www.runoob.com/try/ajax/jsonp.php?jsoncallback=callbackFunction"></script>
</body>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值