Skip to content

Commit 12580b3

Browse files
committed
feat:增加vue3的支持;
1 parent 7f17ca9 commit 12580b3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-x-axios",
33
"description": "基于axios扩展的Vue异步请求插件,为前端实现API统一管理的解决方案。",
4-
"version": "2.4.0",
4+
"version": "2.5.0",
55
"author": "undefined100 <[email protected]>",
66
"license": "MIT",
77
"private": false,

src/lib/vue-x-axios.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,15 @@ let api = {
456456
$api.all = requestArray => {
457457
return batchAjax(requestArray)
458458
}
459-
// 添加全局方法
460-
Vue.$api = $api
461-
// 添加实例方法
462-
Vue.prototype.$api = $api
459+
460+
if (Vue.version.startsWith('3')) {
461+
Vue.config.globalProperties = $api
462+
} else {
463+
// 添加全局方法
464+
Vue.$api = $api
465+
// 添加实例方法
466+
Vue.prototype.$api = $api
467+
}
463468
}
464469
}
465470
export default api

0 commit comments

Comments
 (0)