vue-reqwest
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

vue-reqwest

介绍

requwest 搬运而成的vue插件。

更新

最新版本,同时支撑vue2/3,也能在vue + ts中使用

安装 && 引入

  • npm
npm install --save vue-reqwest
import vueReqwest from 'vue-reqwest';
// 不引入这个将自动注入 reqwest
import reqwest from 'reqwest';

使用 Vue 2:

// 第二个参数可选
Vue.use(vueReqwest[, reqwest]);

使用 Vue 3:

import { createApp } from 'vue';

const app = createApp(...);
// 第二个参数可选
app.use(vueReqwest[, reqwest]);
  • 直接引入
<script src="https://unpkg.com/reqwest"></script>
<script src="https://unpkg.com/vue-reqwest"></script>

使用

Vue.reqwest 或者 this.$ajax 均可调用

注意:

  • vue3 使用app.reqwest
  • 回调函数形式
Vue.reqwest({
  url: 'xxx', 
  method: 'get',
  data: { ... },
  success: function (resp) {
    ...
  }
})
  • Promise形式
this.$ajax({
  url: 'xxx',
  method: 'get',
  data: { ... }
}).then( data => {...} )

API

参看 - reqwest api

Readme

Keywords

Package Sidebar

Install

npm i vue-reqwest

Weekly Downloads

13

Version

1.2.1

License

MIT

Unpacked Size

8.4 kB

Total Files

9

Last publish

Collaborators

  • xiaofan9