vue-io
The HTTP for Vue.js,include ajax & jsonp
Ajax API
- 执行基本ajax请求, 返回XMLHttpRequest
Vue.IO.ajax(url, {
async 是否异步 true(默认)
method 请求方式 POST or GET(默认)
type 数据格式 json(默认) or xml, text
encode 请求的编码 UTF-8(默认)
timeout 请求超时时间 0(默认)
credential 跨域请求时是否带证书(默认false,不带http认证信息如cookie)
data 请求参数 (字符串或json)
}).then(function(res) {
}).catch(function() {
});
Vue.IO.ajax({
url 请求
async 是否异步 true(默认)
method 请求方式 POST or GET(默认)
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.text(url, {
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.json(url, {
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.xml(url, {
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.get(url, {
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.post(url, {
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.sync(url, {
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.async(url, {
...
}).then(function(res) {
}).catch(function() {
});
Vue.IO.get(url)
Vue.IO.get(url, data)
Vue.IO.post(url)
Vue.IO.post(url, data)
Vue.IO.sync(url)
Vue.IO.sync(url, data)
JSONP API
Vue.IO.jsonp(url, {
param
timestamp
jsonpCallback
}).then(function(res) {
}, function() {
});
Vue.IO.jsonp({
url
param
timestamp
jsonpCallback
}).then(function(res) {
}).catch(function() {
})