npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sww-ajax

v1.0.0

Published

ajax

Downloads

2

Readme

axios封装

方便接口统一管理 mock代理请求

使用示例文件

api-Example目录使用示例时重全名为api并移动至工程src/api目录 vue.config-Example代理配置示例文件使用时移动至工程/根目录下

入口引入及页面调用方式

  1. 安装依赖
npm install @gome/ajax
  1. main.js引入
import '@gome/ajax'
  1. 页面中调用
 // 调用方法示例
  this.$ajax.get('/GET/getTest').then((response) => {
    console.log(response);
  }).catch((error) => {
    console.log(error);
  });

  // 推荐调用方式  this.$ajax[模块名称][接口名称](参数); 方便接口统一管理
  this.$ajax.module1.getDetail({id:11122}).then(res => {
    console.log(res)
  })

api文件目录

  |-index.js
  |-modules
  |-modules|-moduleA.js
  |-modules|-moduleB.js
  1. index.js示例

// 1. 所有的 ajax api 在此文件夹下配置
// 2. 根据业务模块,将 api 划分成不同的 modules,放在各自的文件内,单独维护
// 3. 这里提供两个示例模块 - moduleA 与 moduleB,项目中根据业务功能命名。
// 4. 新加的业务模块,需要在 index.js 中注册才能生效,详见:index.js。

/**
 * 
 *  调用方法示例
 *  this.$ajax.get('/GET/getTest').then(function (response) {
      console.log(response);
    }).catch(function (error) {
      console.log(error);
    });

    推荐调用方式  this.$ajax[模块名称][接口名称](参数); 方便接口统一管理
    this.$ajax.module1.getDetail({id:11122}).then(res=>{
      console.log(res)
    })

 */

  import module1 from './modules/moduleA'
  import module2 from './modules/moduleB'

  export default {
    module1,
    module2
  }
  1. moduleA.js示例
/**
 * m: mock
 */
export default (mock)=>{
  return {
    get: {
      getTest: mock.GET + '/getTest',
    },
    postJSON: {
      postTest: mock.POST + '/getList'
    }
  }
};