用于 Vue 全局安装 xe-ajax
Installing
npm install xe-ajax vxe-ajax --save
require.config({
paths: {
'xe-ajax': './dist/xe-ajax.min',
'vxe-ajax': './dist/vxe-ajax.min'
}
})
define(['vue', 'xe-ajax', 'vxe-ajax'], function (Vue, XEAjax, VXEAjax) {
Vue.use(VXEAjax, XEAjax, {context: true})
})
Example
import Vue from 'vue'
import XEAjax from 'xe-ajax'
import VXEAjax from 'vxe-ajax'
Vue.use(VXEAjax, XEAjax)
<template>
<ul>
<li v-for="(item, index) in list" :key="index">{{ item.name }}</li>
</ul>
</template>
<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>
License
Copyright (c) 2017-present, Xu Liangzhan