为 Taro 而设计的 Hooks Library
npm install taro-hooksHooks Library for Taro
- Fully matched Taro
- Extending common hooks with ahooks
- Separate abstraction useRequest
- Complete type tips
- Extended h5 missing apis
``bash`npm
$ npm i taro-hooksyarn
$ yarn add taro-hookspnpm
$ pnpm add taro-hooks
We use plugins for extending different frameworks. So you need to install the corresponding plugins according to the framework you are currently using
- React/PReact/Nerv
`bash`npm
$ npm i @taro-hooks/plugin-reactyarn
$ yarn add @taro-hooks/plugin-reactpnpm
$ pnpm add @taro-hooks/plugin-react
`js`
// config/index.js
module.exports = {
// ...
plugins: ['@taro-hooks/plugin-react'],
// ...
};
- Vue3
`bash`npm
$ npm i @taro-hooks/plugin-vueyarn
$ yarn add @taro-hooks/plugin-vuepnpm
$ pnpm add @taro-hooks/plugin-vue
`js`
// config/index.js
module.exports = {
// ...
plugins: ['@taro-hooks/plugin-vue'],
// ...
};
- React/PReact/Nerv
`jsx
import { useEnv } from 'taro-hooks';
function Index() {
const env = useEnv();
return
}
`
- Vue3
`html
`
We provide the @taro-hooks/plugin-auto-import plugin to help you quickly use the unplugin-auto-import capability.
`bash`npm
$ npm i @taro-hooks/plugin-auto-importyarn
$ yarn add @taro-hooks/plugin-auto-importpnpm
$ pnpm add @taro-hooks/plugin-auto-import
`js`
// config/index.js
const config = {
// ...
// The main prerequisite is that you have installed the plugin for the corresponding framework.
plugins: [
// If you are using vue3, please install the @taro-hooks/plugin-vue plugin beforehand.
'@taro-hooks/plugin-vue',
// If using React/PReact/Nerv, please pre-install the @taro-hooks/plugin-react plugin.
'@taro-hooks/plugin-react',
// Finally, the auto-import plugin is configured
[
'@taro-hooks/plugin-auto-import',
{
// your options, see configuration: https://github.com/antfu/unplugin-auto-import#configuration
}
]
],
// ...
};
- React/PReact/Nerv
`jsx
function Index() {
const env = useEnv();
return
}
`
- Vue3
`html
``
| packages | downloads | version | license |
| :-------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------: |
| !taro-hooks | !taro-hooks | !taro-hooks | !taro-hooks |
| !@taro-hooks/ahooks | !@taro-hooks/ahooks | !@taro-hooks/ahooks | !@taro-hooks/ahooks |
| !@taro-hooks/plugin-vue | !@taro-hooks/plugin-vue | !@taro-hooks/plugin-vue | !@taro-hooks/plugin-vue |
| !@taro-hooks/plugin-react | !@taro-hooks/plugin-react | !@taro-hooks/plugin-react | !@taro-hooks/plugin-react |
| !@taro-hooks/use-request | !@taro-hooks/use-request | !@taro-hooks/use-request | !@taro-hooks/use-request |
| !@taro-hooks/plugin-auto-import | !@taro-hooks/plugin-auto-import | !@taro-hooks/plugin-auto-import | !@taro-hooks/plugin-auto-import |
See Contributing Guide.
innocces 💬 📖 👀 📢 🤔 ⚠️ 📦 📋 🎨 | ryan 📖 📢 🤔 💻 |
MIT.
![]() |
