用于 Vue 全局安装 xe-ajax
npm install xe-ajax vxe-ajax
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/xe-ajax"></script>
<script src="https://cdn.jsdelivr.net/npm/vxe-ajax"></script>
import Vue from 'vue'
import XEAjax from 'xe-ajax'
import VXEAjax from 'vxe-ajax'
Vue.use(VXEAjax, XEAjax)
<template>
<ul>
<li v-for="item in list" :key="item.id">{{ item.name }}</li>
</ul>
</template>
<script>
export default {
data () {
return {
list: []
}
},
created () {
this.$ajax.get('/api/user/list').then(data => {
this.list = data
})
}
}
</script>
MIT © 2017-present, Xu Liangzhan