使用:

npm install axios --save-dev

在main.js中import:

使用:

(1):POST方式

 let data= [{receiveAdd:receiveAddVal, sendAdd:sendAddVal,distance:distance,goodsName:goodsName,editname:editname,weight:weight,editnotename:editnotename,dataTime:dataTime,receiveName:receiveName,receiveSex:receiveSex,receiveTel:receiveTel,sendName:sendName,sendSex:sendSex,sendTel:sendTel,price:price}]
this.$ajax({
method: 'post',
url: 'http://192.168.31.248:8080/sd_tech/PlaceOrder.do',
dataType:'json',
data:{
dataDetail: JSON.stringify(data)
}
}).then(response=>{
alert('post code done')
this.$router.push({path:'/pay'})
}).catch(function(err){
console.log(err)
});

(2):GET方式

 <script>
import $ from 'jquery'
export default {
name: 'totleOrder',
data () {
return {
anylist: []
}
},
mounted () {
this.ready()
},
methods: {
ready: function () {
$.ajax({
type: 'GET',
url: './../../../static/total.json',
data: {},
dataType: 'json'
}).then(res => {
// console.log(res)
// console.log(res.data) // console.log(res.data.length)就是获取到几条数据
this.anylist = res.data
})
.catch(error => {
console.log(error)
})
}
}
}
</script>

vue项目使用axios的更多相关文章

  1. vue项目中 axios 和Vue-axios的关系

    文章收集于:https://segmentfault.com/q/1010000010812113 在vue项目中,会经常看到如下代码:   今天看到有些项目是这样写的,就有点看不懂了.  ----解 ...

  2. vue-cli新建vue项目安装axios后在IE下报错

    使用脚手架新建了一个vue项目,可以在IE9+浏览器运行,但是在添加了axios后,在IE下就报错了 首先是安装axios,在命令行执行: $ npm install axios -s //执行命令, ...

  3. Django day32 跨域问题,创建vue项目,axios的使用

    一:跨域问题 1.同源策略(浏览器的安全策略) 只允许当前页面朝当前域下发请求,如果向其他域发请求,请求可以正常发送,数据也可以拿回,但是被浏览器拦截了 2.cors:只要服务器实现了CORS,就可以 ...

  4. vue项目对axios的全局配置

    标准的vue-cli项目结构(httpConfig文件夹自己建的): api.js: //const apiUrl = 'http://test';//测试域名,自己改成自己的 const apiUr ...

  5. vue项目使用axios发送请求让ajax请求头部携带cookie

    最近做vue项目时遇到登录权限问题,登录以后再发送的请求头部并没有携带登录后设置的cookie,导致后台无法校验其是否登录.检查发现是vue项目中使用axios发送ajax请求导致的.查看文档得知ax ...

  6. vue项目,axios请求图片接口,接口返回的是文件流的形式,如何转换成图片?

    axios .get('/captcha', { params: param, responseType: 'arraybuffer' }) .then(response => { return ...

  7. 15、vue项目封装axios并访问接口

    1.在src下新建util文件夹,在util下新建request.js文件: 封装axios: import axios from 'axios' import QS from 'qs'; // im ...

  8. vue项目中axios的封装和使用

    一.axios的功能特点 在浏览器中发送 XMLHttpRequests 请求 在 node.js 中发送 http请求 支持 Promise API 拦截请求和响应 转换请求和响应数据 支持多种请求 ...

  9. 关于vue项目中axios跨域的解决方法(开发环境)

    1.在config文件中修改index.js proxyTable: { "/api":{ target: 'https://www.baidu.com/muc/',//你需要跨域 ...

随机推荐

  1. 基于Linux的智能家居的设计(2)

    1  系统整体设计方案 智能家居系统的是一个实时查询家庭的温湿度.照明控制.自己主动控制的设定.集家庭娱乐.智能安防为一体,大量数据快处理.可靠的系统,因此在硬件和软件上都有非常大的要求,因此在这里进 ...

  2. HTML——上中下布局

    上中下布局是最主要的布局方式,本比如果用户屏幕分辨率为800*600像素. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3Vuc2h1bWlu/font ...

  3. 改动npm包管理器的registry为淘宝镜像(npm.taobao.org)

    起因 安装了node.安装了npm之后,官方的源实在是 太慢了! 看了看淘宝的npm镜像, http://npm.taobao.org/  居然说让我再下载一个cnpm,要不然就每次都得install ...

  4. webpack02

    consumer-index.html <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

  5. sklearn preprocessing 数据预处理(OneHotEncoder)

    1. one hot encoder sklearn.preprocessing.OneHotEncoder one hot encoder 不仅对 label 可以进行编码,还可对 categori ...

  6. POJ 1986 裸的LCA

    思路:搞了一发链剖 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> ...

  7. Inter-process Communication (IPC)

    For Developers‎ > ‎Design Documents‎ > ‎ Inter-process Communication (IPC) 目录 1 Overview 1.1 I ...

  8. 实现人脸识别性别之路---网页上的video标签

    <video> 元素支持三种视频格式: MP4, WebM, 和 Ogg.但是,不同的浏览器对视频格式的支持也不一致,因此为了让浏览器都适应,我们使用source属性来对视频文件格式定义 ...

  9. react基础用法一(在标签中渲染元素)

    react基础用法一(渲染元素) 如图所示最简单的变量使用方法 格式 let 变量名称 = 赋值: 渲染格式直接用 {变量名称} 就可以直接渲染到页面 如图所示第二种渲染方法 格式 const 变量名 ...

  10. RvmTranslator6.0 - AVEVA Marine Hull Model

    eryar@163.com 1. Introduction RvmTranslator can translate the RVM file exported by AVEVA Plant(PDMS) ...