axios安装及使用
使用npm安装
$ npm install axios
使用 bower安装
$ bower install axios
使用 cdn:
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
main.js:导入
import axios from 'axios'
调用接口使用axios:
1: 接口数据读取
querygraphic () {
let _this = this
this.$http.get('https://localhost:44314/api/Values').then(res => {
_this.list = res.data
})
data () {
return {
list: []
}
调用赋值:v-for="queryg in list":key="queryg.id" {{ queryg.version }}
2:按id数据读取
getgrid () {
this.$http.get('https://localhost:44314/api/Values/' + this.id).then(res => {
this.gettext = res.data[]
console.log(this.gettext)
})
data () {
return {
id: this.$route.params.id, // 读取路由传过来的id
gettext: {}
}
},
调用赋值:
{{ gettext.text }}
3:put更新
this.$http({
url: 'https://localhost:44314/api/Gj/' + this.id,
method: 'put',
contentType: 'application/json;charset=UTF-8',
data: {
'id': this.newinfo.id,
'method': this.newinfo.method,
'text': this.newinfo.text,
'type': this.newinfo.type
},
dataType: 'json'
}).then(res => {
console.log(res)
if (res.status === ) {
this.open1()
console.log('成功')
} else {
this.open4()
console.log('失败')
}
}).catch(console.error.bind(console)) // 异常
4:delete删除
this.$http.delete('https://localhost:44314/api/Gj/' + row.id).then(res => {
if (res.status === ) {
this.$message({
type: 'success',
message: '删除成功!'
})
this.getgjtype('vue') // 重新加载数据
this.reload() // 刷新页面
// location.reload()// 刷新页面
// this.$router.go(0)
} else {
this.open4()
}
}).catch(console.error.bind(console)) // 异常
axios安装及使用的更多相关文章
- vuejs axios安装配置与使用
1.安装服务 npm install --save axios vue-axios 2.在main.js import axios from 'axios' import VueAxios from ...
- vue+axios安装
Axios是一个基于promise的HTTP库,可以用在浏览器和node.js中. 安装方式: 1.使用cdn <script src="https://unpkg.com/axios ...
- 搭建vue脚手架,包含Axios、qs、Element-UI、mock等插件的安装配置
1.安装node.vue这些最基础最简单的安装的就一一省略过. 1.1 axios 安装 1.2安装 Element-Ui 插件 1.3 安装 qs 1.4 安装 Mock 2.新建一个vue工程, ...
- VUE:使用vue-cli脚手架无法安装npm install axios 的巨坑
使用命令 npm install axios 安装axios可能会报错,无法引用, 这个时候使用淘宝的镜像cnpm安装就可以了 cnpm install axios 如果没有安装cnpm,执行以下命令 ...
- vue3.x版本安装element-ui、axios及echarts图表插件
项目中安装使用element-UI 命令行: vue add element 安装成功后,项目会自动将element-UI引入项目中,刷新项目即可 项目中安装使用axios数据请求 vue add a ...
- ThinkPHP6.0 + Vue + ElementUI + axios 的环境安装到实现 CURD 操作!
官方文档地址: ThinkPHP6.0: https://www.kancloud.cn/manual/thinkphp6_0/1037479 ElemetUI: https://elemen ...
- axios基本用法
vue更新到2.0之后,作者就宣告不再对vue-resource更新,而是推荐的axios,前一段时间用了一下,现在说一下它的基本用法. 首先就是引入axios,如果你使用es6,只需要安装axios ...
- Axios使用说明
vue更新到2.0之后,作者就宣告不再对vue-resource更新,而是推荐的axios,前一段时间用了一下,现在说一下它的基本用法. 首先就是引入axios,如果你使用es6,只需要安装axios ...
- Vue.js 2.x笔记:服务请求axios(8)
1. axios简介 vue2.0之后,推荐使用axios. axios官方地址:https://github.com/axios/axios 2. axios安装 npm安装: npm instal ...
随机推荐
- apache配置项
环境:apache2.24 apache 官方文档:http://httpd.apache.org/docs/2.4/ 全部指令索引: http://httpd.apache.org/docs/ ...
- vue router 导航守卫生命周期
导航守卫 导航守卫主要用来通过跳转或取消的方式守卫导航.有多种机会植入路由导航过程中:全局的, 单个路由独享的, 或者组件级的.(记住参数或查询的改变并不会触发进入/离开的导航守卫.你可以通过观察$r ...
- 201871010134-周英杰《面向对象程序设计(java)》第十五周学习总结
项目 内容 这个作业属于哪个课程 <任课教师博客主页链接>https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 <作业链接地址>http ...
- python-分割url字符串
url = ' http://images.jupiterimages.com/common/detail/27/68/22986827.jpg' url.strip().split('/')[-1] ...
- Tkinter--Text文本框样例
#-*- coding:utf-8 -*- """ Text 文本框样例 实现功能有:Ctrl+a全选文本, 竖向滚动条,横向滚动条(不自动换行) 自动缩放 有谁知道全选 ...
- python27期day02:while循环、break、格式化、运算符、编码初始、作业题。
1.while循环:不断的重复着某件事就是循环 2.while循环图解: 3.break:终止当前循环. 4.continue就是跳出本次循环.继续下次循环. 下方代码都不会执行. 改变循环条件来终止 ...
- plantUML 安装
plantUML 安装 资源 http://www.graphviz.org/ https://graphviz.gitlab.io/_pages/Download/windows/graphviz- ...
- springboot2.1+redis多数据源的配置
springboot系列学习笔记全部文章请移步值博主专栏**: spring boot 2.X/spring cloud Greenwich. 由于是一系列文章,所以后面的文章可能会使用到前面文 ...
- 树莓派autossh反向隧道
本来我是将树莓派连接到路由器,从而在电脑端通过IP访问.远在局域网之外的队友怎么访问呢? ssh反向隧道 它的原理比较简单: 树莓派主动向某公网服务器建立ssh连接,并请求公网服务器开启一个额外的SS ...
- Linux学习笔记-第2天- 新的开始
迟到且稀疏的笔记,希望自己今年会有所突破.加油