@zq741235/vue-cli-plugin-axios

1.0.7 • Public • Published

@zq741235/vue-cli-plugin-axios

安装

vue add @zq741235/axios

使用

1.添加自己的api到模块里(如:src/api/module)

// src/api/module/xx
export const GET_XX = '/api/XX'

2.在src/api/index中全量导出

export * from './module/xx'

3.页面导入

import {GET_XX} from '@/api' // @为src

4.页面引用

this.$_get(GET_xx).then(res=>{})
this.$_get(GET_xx,{paramsA:11,paramsB:22}).then(res=>{})
this.$_post(GET_xx).then(res=>{})
this.$_post(GET_xx,{paramsA:11,paramsB:22}).then(res=>{})
this.$_post(GET_xx,{paramsA:11,paramsB:22},{
    // 第三个可以传axios配置的参数
}).then(res=>{})

其他

配合zq741235/router可直接查看示例

http://localhost:8080/axios

vue-cli-plugin-router

vue add @zq741235/router

一键安装基础模版

vue create --preset zq741235/vue-cli-plugins my-project

Readme

Keywords

Package Sidebar

Install

npm i @zq741235/vue-cli-plugin-axios

Weekly Downloads

4

Version

1.0.7

License

ISC

Unpacked Size

6.61 kB

Total Files

12

Last publish

Collaborators

  • zq741235