Comparing version 1.3.5 to 1.3.6
@@ -1,8 +0,11 @@ | ||
/*! | ||
* vxe-ajax.js v1.3.5 | ||
/** | ||
* vxe-ajax.js v1.3.6 | ||
* (c) 2017-2018 Xu Liangzhan | ||
* ISC License. | ||
* @preserve | ||
*/ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.VXEAjax = factory()) | ||
typeof s === 'object' && typeof module !== 'undefined' ? module.s = factory() | ||
: typeof define === 'function' && define.amd ? define(factory) | ||
: (global.VXEAjax = factory()) | ||
}(this, function () { | ||
@@ -44,3 +47,3 @@ 'use strict' | ||
function plugin (Vue, XEAjax, isContext) { | ||
function VXEAjax (Vue, XEAjax, isContext) { | ||
Object.defineProperty(Vue.prototype, '$ajax', { | ||
@@ -57,3 +60,3 @@ get: function () { | ||
return plugin | ||
return VXEAjax | ||
})) |
@@ -1,6 +0,7 @@ | ||
/*! | ||
* vxe-ajax.js v1.3.5 | ||
/** | ||
* vxe-ajax.js v1.3.6 | ||
* (c) 2017-2018 Xu Liangzhan | ||
* ISC License. | ||
* @preserve | ||
*/ | ||
(function(b,a){typeof exports==="object"&&typeof module!=="undefined"?module.exports=a():typeof define==="function"&&define.amd?define(a):(b.VXEAjax=a())}(this,function(){function b(e,d){return typeof e==="function"?e.bind(d):e}function c(e,d){this.promise=e instanceof Promise?e:new Promise(e.bind(d));this.context=d}c.prototype.then=function(e,d){return new c(this.promise.then(b(e,this.context),b(d,this.context)),this.context)};c.prototype.catch=function(d){return new c(this.promise.catch(b(d,this.context)),this.context)};c.all=function(e,d){return new c(Promise.all(e),d)};c.race=function(e,d){return new c(Promise.race(e),d)};c.resolve=function(e,d){return new c(Promise.resolve(e),d)};c.reject=function(e,d){return new c(Promise.reject(e),d)};function a(f,d,e){Object.defineProperty(f.prototype,"$ajax",{get:function(){if(e){d.$context=this;d.$Promise=c}return d}})}return a})); | ||
!function(t,e){"object"==typeof s&&"undefined"!=typeof module?module.s=e():"function"==typeof define&&define.amd?define(e):t.VXEAjax=e()}(this,function(){"use strict";function t(t,e){return"function"==typeof t?t.bind(e):t}function e(t,e){this.promise=t instanceof Promise?t:new Promise(t.bind(e)),this.context=e}return e.prototype.then=function(n,o){return new e(this.promise.then(t(n,this.context),t(o,this.context)),this.context)},e.prototype.catch=function(n){return new e(this.promise.catch(t(n,this.context)),this.context)},e.all=function(t,n){return new e(Promise.all(t),n)},e.race=function(t,n){return new e(Promise.race(t),n)},e.resolve=function(t,n){return new e(Promise.resolve(t),n)},e.reject=function(t,n){return new e(Promise.reject(t),n)},function(t,n,o){Object.defineProperty(t.prototype,"$ajax",{get:function(){return o&&(n.$context=this,n.$Promise=e),n}})}}); |
@@ -34,3 +34,3 @@ function bindPromiseContext (callback, context) { | ||
function plugin (Vue, XEAjax, isContext) { | ||
function VXEAjax (Vue, XEAjax, isContext) { | ||
Object.defineProperty(Vue.prototype, '$ajax', { | ||
@@ -47,2 +47,2 @@ get: function () { | ||
export default plugin | ||
export default VXEAjax |
{ | ||
"name": "vxe-ajax", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "VXEAjax 用于Vue全局安装 xe-ajax", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,19 +8,22 @@ # VXEAjax 用于Vue全局安装 xe-ajax | ||
### 兼容性 | ||
任何支持 Promise 的环境都能运行,低版本浏览器使用 polyfill<br/> | ||
## 兼容性 | ||
基于 Promise 实现,低版本浏览器使用 polyfill es6-promise.js | ||
支持 IE8+、Edge、Chrome、Firefox、Opera、Safari等... | ||
### CDN 安装 | ||
使用 script 方式安装,VXEAjax 会定义为全局变量<br/> | ||
## CDN 安装 | ||
使用 script 方式安装,VXEAjax 会定义为全局变量 | ||
生产环境请使用 vxe-ajax.min.js,更小的压缩版本,可以带来更快的速度体验。 | ||
#### cdnjs 获取最新版本, [点击浏览](https://cdn.jsdelivr.net/npm/vxe-ajax/)已发布的所有 npm 包的源代码。 | ||
### cdnjs 获取最新版本 | ||
[点击浏览](https://cdn.jsdelivr.net/npm/vxe-ajax/)已发布的所有 npm 包源码 | ||
``` shell | ||
<script src="https://cdn.jsdelivr.net/npm/vxe-ajax@1.3.5/dist/vxe-ajax.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vxe-ajax/dist/vxe-ajax.js"></script> | ||
``` | ||
#### unpkg 获取最新版本, [点击浏览](https://unpkg.com/vxe-ajax@1.3.5/)已发布的所有 npm 包的源代码 | ||
### unpkg 获取最新版本 | ||
[点击浏览](https://unpkg.com/vxe-ajax/)已发布的所有 npm 包源码 | ||
``` shell | ||
<script src="https://unpkg.com/vxe-ajax@1.3.5/dist/vxe-ajax.js"></script> | ||
<script src="https://unpkg.com/vxe-ajax/dist/vxe-ajax.js"></script> | ||
``` | ||
### AMD 安装, 以 require.js 为例 | ||
## AMD 安装 | ||
### require.js 安装示例 | ||
``` shell | ||
@@ -38,18 +41,7 @@ // require 配置 | ||
define(['vue', 'xe-ajax', 'vxe-ajax'], function (Vue, XEAjax, VXEAjax) { | ||
// (v1.3.5+)如果第三个参数设置为true,则启动模拟 Promise 模式(默认是false) | ||
// 通过 this.$ajax 发起的请求 this 默认指向当前vue实例。 | ||
Vue.use(VXEAjax, XEAjax, true) | ||
}) | ||
// ./app.js 调用 | ||
define([], function () { | ||
// 通过vue实例的调用方式 | ||
// ...vue代码省略 | ||
this.$ajax.getJSON('/api/user/list', {id: 1}).then(data => { | ||
this.list = [] // (v1.3.5+)需要启动模拟 Promise 模式才支持 this 默认指向 vue 实例 | ||
}) | ||
}) | ||
``` | ||
### ES6 Module 安装方式 | ||
## ES6 Module 安装 | ||
``` shell | ||
@@ -72,4 +64,4 @@ npm install xe-ajax vxe-ajax --save | ||
### 混合函数 | ||
#### 文件 ./customs.js | ||
## 混合函数 | ||
### 文件 ./customs.js | ||
``` shell | ||
@@ -80,3 +72,3 @@ export function get1 () { | ||
``` | ||
#### 示例 | ||
### 示例 ./main.js | ||
``` shell | ||
@@ -95,3 +87,3 @@ import Vue from 'vue' | ||
#### 案例 | ||
## 示例 | ||
./Home.vue | ||
@@ -98,0 +90,0 @@ ``` shell |
93
8648
118