|
1 |
| -# mpxuse |
2 |
| -composition-api的公用方法 |
| 1 | +<p align="center"> |
| 2 | +<a href="https://github.com/mpx-ecology/mpxuse#gh-light-mode-only"> |
| 3 | + <img src="https://raw.githubusercontent.com/mpx-ecology/mpxuse/main/packages/public/logo-vertical.png#gh-light-mode-only" alt="Mpxuse - Mpx的composition-api的公用方法" width="300"> |
| 4 | +</a> |
| 5 | +<a href="https://github.com/mpx-ecology/mpxuse#gh-dark-mode-only"> |
| 6 | + <img src="https://raw.githubusercontent.com/mpx-ecology/mpxuse/main/packages/public/logo-vertical-dark.png#gh-dark-mode-only" alt="Mpxuse - Mpx的composition-api的公用方法" width="300"> |
| 7 | +</a> |
| 8 | +<br> |
| 9 | +Mpx的composition-api的公用方法 |
| 10 | +</p> |
| 11 | + |
| 12 | +<p align="center"> |
| 13 | +<a href="https://www.npmjs.com/package/@mpxjs/mpxuse-core" target="__blank"><img src="https://img.shields.io/npm/v/@mpxjs/mpxuse-core?color=a1b858&label=" alt="NPM version"></a> |
| 14 | +<a href="https://www.npmjs.com/package/@mpxjs/mpxuse-core" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@mpxjs/mpxuse-core?color=50a36f&label="></a> |
| 15 | +<a href="https://mpx-ecology.github.io/mpxuse" target="__blank"><img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20demos&color=1e8a7a" alt="Docs & Demos"></a> |
| 16 | +<img alt="函数数量" src="https://raw.githubusercontent.com/mpx-ecology/mpxuse/main/packages/public/badge-function-count.svg"> |
| 17 | +<br> |
| 18 | +<a href="https://github.com/mpx-ecology/mpxuse" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/mpx-ecology/mpxuse?style=social"></a> |
| 19 | +</p> |
| 20 | + |
| 21 | +## 🚀 功能 |
| 22 | + |
| 23 | +- 🎪 [**文档和演示**](https://mpx-ecology.github.io/mpxuse) |
| 24 | +- 🕶 **支持版本**: mpx2.8版本以上 |
| 25 | +- ⚡ **完全tree shakeable**: 仅打包所引用的, [bundle size](https://mpx-ecology.github.io/mpxuse/export-size) |
| 26 | +- 🦾 **Type Strong**: [TypeScript](https://www.typescriptlang.org/)编写, [TS Docs](https://github.com/microsoft/tsdoc) |
| 27 | +- 🔩 **灵活配置**: 可配置的事件筛选器和目标 |
| 28 | + |
| 29 | +## 🦄 用法 |
| 30 | + |
| 31 | +```ts |
| 32 | +import { useCounter } from '@mpxjs/mpxuse-core' |
| 33 | + |
| 34 | +const { count, inc, dec, set, reset } = useCounter() |
| 35 | +defineExpose({ |
| 36 | + count, inc, dec, set, reset |
| 37 | +}) |
| 38 | +``` |
| 39 | + |
| 40 | +```html |
| 41 | +<template> |
| 42 | + <view> |
| 43 | + <view>Count: {{ count }}</view> |
| 44 | + <button bindtap="inc"> |
| 45 | + Increment |
| 46 | + </button> |
| 47 | + <button bindtap="dec"> |
| 48 | + Decrement |
| 49 | + </button> |
| 50 | + <button bindtap="inc(5)"> |
| 51 | + Increment (+5) |
| 52 | + </button> |
| 53 | + <button bindtap="dec(5)"> |
| 54 | + Decrement (-5) |
| 55 | + </button> |
| 56 | + <button bindtap="set(100)"> |
| 57 | + Set (100) |
| 58 | + </button> |
| 59 | + <button bindtap="reset"> |
| 60 | + Reset |
| 61 | + </button> |
| 62 | + </view> |
| 63 | +</template> |
| 64 | + |
| 65 | +``` |
| 66 | + |
| 67 | +参考 [所有函数](https://mpx-ecology.github.io/mpxuse/functions) 或者 [文档](https://mpx-ecology.github.io/mpxuse/) 查看更多 |
| 68 | + |
| 69 | +## 📦 安装 |
| 70 | + |
| 71 | +> 🎩 mpx版本需要2.8以上才支持组合式Composition API! |
| 72 | +
|
| 73 | +```bash |
| 74 | +npm i @mpxjs/mpxuse-core |
| 75 | +``` |
| 76 | + |
| 77 | +###### Demos |
| 78 | + |
| 79 | +可clone仓库执行 |
| 80 | + |
| 81 | +```js |
| 82 | +pnpm i |
| 83 | +cd demo && pnpm i |
| 84 | +npm run watch |
| 85 | +``` |
| 86 | + |
| 87 | +## 🧱 贡献 |
| 88 | + |
| 89 | +参考 [**如何共建**](https://mpx-ecology.github.io/mpxuse/contributing) |
| 90 | + |
| 91 | +## 🌸 感谢 |
| 92 | + |
| 93 | +这个项目的灵感来源于以下几个很棒的项目。 |
| 94 | + |
| 95 | +- [vueuse/vueuse](https://github.com/vueuse/vueuse) |
| 96 | + |
| 97 | +## 👨🚀 贡献者 |
| 98 | + |
| 99 | +[pagnkelly](https://github.com/pagnkelly) |
| 100 | + |
| 101 | +## 📄 License |
| 102 | + |
| 103 | +[MIT License](https://github.com/mpx-ecology/mpxuse/blob/main/LICENSE) © 2022 [pagnkelly](https://github.com/pagnkelly) |
0 commit comments