ajax请求插件vue-resource的学习
来源:互联网 发布:linux 查看cpu参数 编辑:程序博客网 时间:2024/06/11 04:38
http://cn.vuejs.org/guide/plugins.html
ajax请求插件vue-resource的学习
https://github.com/vuejs/vue-resource/blob/master/README.md
1、安装
npm install vue-resource
2、使用
import VueResource from 'vue-resource';Vue.use(VueResource);
this.$http.get("http://localhost/test.php").then( function (res) { // 处理成功的结果 alert(res.body); },function (res) { // 处理失败的结果 } );
传递数据到后端
this.$http.post("http://localhost/test.php",{name:"zhangsan"},{emulateJSON:true}).then( function (res) { // 处理成功的结果 alert(res.body); },function (res) { // 处理失败的结果 } );
3、test.php
<?php// 指定允许其他域名访问header('Access-Control-Allow-Origin:*');// 响应类型header('Access-Control-Allow-Methods:GET,POST,PUT');header('Access-Control-Allow-Headers:x-requested-with,content-type');var_export($_POST);die('hello');
2 0
- ajax请求插件vue-resource的学习
- ajax请求插件vue-resource的学习
- ajax请求插件vue-resource的学习
- vue使用resource发送ajax请求
- vue的ajax库 ----- vue-resource
- vue插件:vue-resource的使用笔记
- vue插件:vue-resource的使用笔记
- Vue-resource实现ajax请求和跨域请求
- 关于使用vue 的resource插件用post请求数据时一直是options的解决方案
- vue-resource post请求的坑
- ajax 跨域请求 vue-resource jsonp跨域
- vue学习第21天,vue-resource 插件
- vue+vue-resource post请求
- vue 的ajax请求数据
- vue-resource插件使用
- vue-resource插件使用
- vue-resource插件使用
- vue-resource插件使用
- Linux内核结构
- 2016.10.30
- Java JNI调用dll中的C代码的流程
- Python 字符串
- 核心绘图——Core Graphics
- ajax请求插件vue-resource的学习
- 14. Sphinx 站内搜索
- Android逆向实例笔记—在so里对游戏的修改
- 关于一次线上事故总结,以及对于mysql索引的总结(序言一)
- android中xml tools属性详解
- hdu2049不容易系列之(4)——考新郎
- Android复习之旅--文件存储
- C++字符串删除函数
- unity shader入门指南与总结