Git Product home page Git Product logo

wxa's Introduction

Decorate your wechat mini-program

Travis Status Travis Status node (scoped with tag, custom registry) Licence

@wxa

🎉🎉🎉AOP Framework for writing wechart mini-program.

💯More detail documents

💯更完善的文档

简介

wxa是一个AOP框架,主要使用Decorator(运行时改写,拦截)和预编译实现框架功能。

使用 Decorator 实现了:

Fetch 队列管理网络请求,单个请求自动防重。

Router 简洁的API、预加载特性。

Lock 防止重复执行函数,前端防重利器。

Debounnce 防抖动。

Mixin 混合代码,代码复用。

查看详细的 Class Decorators Method Decorators

预编译方面,实现了对小程序项目的依赖解析,利用依赖树对整个项目进行管理,以此为基础适配了npm、单文件开发、云开发、三方开发。开发语法方面支持最新的ES*语法(包括Async/Await)、Sass/Scss、Stylus,有需求的话可以适配更多语法。

跟wepy相比有以下优势:

  • wxa完全采用原生小程序的组件化方案,2.0已经适配了有赞Vant-weapp和echarts了。
  • 超低迁移成本,原生小程序只需要安装好相关依赖就可以马上在@wxa/cli中跑起来。支持原生和wxa混杂开发。
  • 三方开发,支持一次性编译出多个三方项目

Install

使用 yarnnpm 全局安装

npm i -g @wxa/cli2

Quick Started

定义App类并导出:

import {App} from '@wxa/core';

@App
export default class Main {
    globalData = {
        userInfo: 'Genuifx',
    }
}

定义页面类并导出:

// 引入core包提供的Decorator
import {Page, Debounce} from '@wxa/core';

// 挂载常用的方法到页面类
// 导出一个默认的页面类
@Page
export default class Index { 
    // 页面方法用于响应用户操作,函数自动防抖动
    @Debounce(300)
    tap() {
        // 通过$storage缓存数据
        this.$storage.set('TAP', true);
    }
}

默认导出的方法将会自动调用小程序相应的 PageComponentApp 方法进行注册。

更完善的文档

Contribution

欢迎各种 PRISSUE

LICENSE

MIT

wxa's People

Contributors

biaodoit avatar genuifx avatar hanzooo avatar szyuan avatar zcfan avatar zehuiguan avatar

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.