新闻动态
新闻动态
- User.Identity.Name介绍1
- C#设计模式(2)——简单工厂模式
- 如何做热门关键词
- .NET C#获取当前网页地址信息
- ASP.NET 一个web页面的生命周期是什么?
- 移动控件介绍及详细使用方法:AdRotator移动控件
- sql语句中怎样比较两个日期的大小
- round函数
- 伪静态下不能使用FCKeditor的解决方案
- SEO之关键词选择实战经验(实用)
联系我们
邮箱:
手机:15383239821
前端设计
axios和vue-resource的对比和使用
作者:
发布时间:2023-01-13
点击:
axios和vue-resource的对比
vue-resource: vue插件, 多用于vue1.x
axios: 第三方库, 多用于vue2.x
vue-resource使用
// 引入模块
import VueResource from 'vue-resource'
// 使用插件
Vue.use(VueResource)
// 通过vue/组件对象发送ajax请求
this.$http.get('/someUrl').then((response) => {
// success callback
console.log(response.data) //返回结果数据
}, (response) => {
// error callback
console.log(response.statusText) //错误信息
})
axios使用
// 引入模块
import axios from 'axios'
// 发送ajax请求
axios.get(url)
.then(response => {
console.log(response.data) // 得到返回结果数据
})
.catch(error => {
console.log(error.message)
})
- 上一篇:模板字符串
- 下一篇:axios与vue-resource 比较
新闻资讯
-
2020-07-29一个好的网店运营需要具备哪些能力
-
2023-10-08请求变量
-
2023-09-21php如何是用define让他起到全局的常量的作用
-
2014-02-24HTML 标准属性
-
2012-06-30SEO中导致网站降权具体表现及解决办法
-
2013-08-28Asp.net非常实用的51个代码(2)
相关案例
