Comparing version 1.4.2 to 1.4.3
@@ -15,3 +15,3 @@ import Vue from 'vue' | ||
interface Vue { | ||
$ajax: XEAjaxMethods | ||
$ajax: XEAjaxMethods; | ||
} | ||
@@ -18,0 +18,0 @@ } |
{ | ||
"name": "vxe-ajax", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "A small wrapper for integrating xe-ajax to Vuejs.", | ||
@@ -8,4 +8,17 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "make test" | ||
"lint": "eslint dist/vxe-ajax.js index.js", | ||
"test": "npm run lint" | ||
}, | ||
"devDependencies": { | ||
"vue": "^2.5.17", | ||
"xe-utils": "^1.6.23", | ||
"eslint": "^5.9.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-friendly-formatter": "^4.0.1", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-node": "^8.0.0", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"markdown-doctest": "^0.9.1" | ||
}, | ||
"repository": { | ||
@@ -16,7 +29,7 @@ "type": "git", | ||
"keywords": [ | ||
"ajax", | ||
"ajax.js", | ||
"vue-ajax", | ||
"xe-ajax", | ||
"vxe-ajax", | ||
"xe" | ||
"XEAjax" | ||
], | ||
@@ -31,7 +44,3 @@ "author": { | ||
}, | ||
"homepage": "https://github.com/xuliangzhan/vxe-ajax#readme", | ||
"devDependencies": { | ||
"vue": "^2.5.16", | ||
"xe-ajax": "^3.4.12" | ||
} | ||
"homepage": "https://github.com/xuliangzhan/vxe-ajax#readme" | ||
} |
# 用于 Vue 全局安装 xe-ajax | ||
[![npm version](https://img.shields.io/npm/v/vxe-ajax.svg?style=flat-square)](https://www.npmjs.org/package/vxe-ajax) | ||
[![npm build](https://travis-ci.org/xuliangzhan/vxe-ajax.svg?branch=master)](https://travis-ci.org/xuliangzhan/vxe-ajax) | ||
[![npm downloads](https://img.shields.io/npm/dm/vxe-ajax.svg?style=flat-square)](http://npm-stat.com/charts.html?package=vxe-ajax) | ||
[![npm license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/xuliangzhan/vxe-ajax/blob/master/LICENSE) | ||
## AMD 安装 | ||
## Installing | ||
```JavaScript | ||
npm install xe-ajax vxe-ajax --save | ||
``` | ||
```JavaScript | ||
// require 配置 | ||
@@ -17,4 +23,2 @@ require.config({ | ||
}) | ||
// ./main.js 安装 | ||
define(['vue', 'xe-ajax', 'vxe-ajax'], function (Vue, XEAjax, VXEAjax) { | ||
@@ -26,11 +30,5 @@ // 非 ES6 环境中如果需要启用模拟 Promise 模式对vue 实例上下文的支持(和 ES6 箭头函数效果一样),设置 {context: true} | ||
## NPM 安装 | ||
## Example | ||
```JavaScript | ||
npm install xe-ajax vxe-ajax --save | ||
``` | ||
### 通过 Vue.use() 来全局安装 | ||
```JavaScript | ||
import Vue from 'vue' | ||
@@ -43,10 +41,28 @@ import XEAjax from 'xe-ajax' | ||
## 使用 | ||
```html | ||
<template> | ||
<ul> | ||
<li v-for="(item, index) in list" :key="index">{{ item.name }}</li> | ||
</ul> | ||
</template> | ||
``` | ||
```JavaScript | ||
this.$ajax.fetch('/api/user/list').then(response => { | ||
response.json().then(data => { | ||
console.log(data) | ||
}) | ||
}) | ||
```html | ||
<script> | ||
export default { | ||
name: 'App', | ||
data: { | ||
return { | ||
list: [] | ||
} | ||
}, | ||
created () { | ||
this.$ajax.fetch('/api/user/list').then(response => { | ||
response.json().then(data => { | ||
this.list = data | ||
}) | ||
}) | ||
} | ||
} | ||
</script> | ||
``` | ||
@@ -53,0 +69,0 @@ |
69
6337
10
82