GithubHelp home page GithubHelp logo

yuweizhang1991 / wux-weapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wux-weapp/wux-weapp

0.0 0.0 0.0 36.26 MB

:dog: 微信小程序自定义 UI 组件

Home Page: https://wux-weapp.github.io/wux-weapp

License: MIT License

JavaScript 100.00%

wux-weapp's Introduction

Wux Weapp

微信小程序自定义 UI 组件

npm version

快速上手

使用之前

在开始使用之前,你需要先阅读 微信小程序自定义组件 的相关文档。

如何使用

首先到 GitHub 下载 Wux Weapp 的代码,然后 将dist/ 目录拷贝到自己的项目中。按照如下的方式使用组件,以 Badge 为例,其它组件在对应的文档页查看:

在 page.json 中引入组件

"usingComponents": {
    "wux-badge": "../../dist/badge/index"
}

在 page.wxml 中使用组件

<wux-badge count="22" />
<wux-badge count="44" />
<wux-badge count="66" />

组件库文件体积过大的问题

随着组件库越来越丰富,文件的体积也越来越大,某些时候我们可能只需要其中的一个或多个组件,如果直接引入整个组件库的话是不合适的,这时候就需要我们将要使用到组件给单独抽离出来,也很简单直接拷贝 dist/ 目录下对应的组件即可,当然某些组件存在依赖关系,则抽离过程会相对复杂一些,以 ActionSheet、Badge、Button 为例。

demo/
  |-actionsheet/
  |-animation-group/
  |-backdrop/
  |-badge/
  |-button/
  |-helpers/
  |-index.js
  • 首先将 dist/ 目录下对应组件(如 actionsheet)拷贝至 demo 目录;
  • 其次看其对应目录下 index.json 是否存在依赖组件,若存在则一一拷贝;
  • 然后看组件是否依靠 JavaScript 主动调用(查看对应文档可得知或存在 index.js 文件中),是则拷贝 index.js 文件,并删除不需要的组件引用;
  • 最后查看组件目录下 index.js 是否存在对帮助方法的引用,若存在则拷贝 helpers 目录(抑或直接拷贝不管是否存在引用)。

预览

您可以扫描下方的小程序码体验或用 微信web开发者工具 打开 example 目录(请注意,是 example 目录,不是整个项目)。

logo

文档

Document

讨论组

您可以扫描下方的小助手微信并备注 Wux Weapp 进交流群。

贡献

有任何意见或建议都欢迎提 issue

License

MIT

wux-weapp's People

Contributors

skyvow avatar genru avatar derekhe avatar drunksword 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.