Giter Site home page Giter Site logo

taro-kit's Introduction

可以watch 这个项目,有更新,及时知道

项目会不断迭代,有需求欢迎issue 如果能帮到你,那就给个star呗!

文章

功能列表

  • 封装api请求方式
  • 更方便的创建action:增加createApiAction
  • 基础像素试着为1倍即:1px 会编译成 2rpx(小程序默认是2倍)符合习惯
  • 基础demo案列

用法

npm i

npm start

更优雅的创建action

未封装前

function articleList(data) {
  return { type: LIST, payload: data }
}

export function list() {
  console.log('list')
  return (dispatch) => {
    // service.get('/v1/article/list')
    //   .then((res) => {
    //     dispatch(articleList(res.data.article))
    //   })

    Taro.request({
      url: 'http://api.shudong.wang/v1/article/list',
      data: {
        foo: 'foo',
        bar: 10
      },
      header: {
        'content-type': 'application/json'
      }
    }).then((res) => {
      dispatch(articleList(res.data.article))
    })
  }
}

2018-09-25-15-50-45

封装后请求api的使用方式

export const list = createApiAction(LIST, params => api.get('news/list', params))

2018-09-25-15-51-45

taro-kit's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.