首先进入 官方文档
https://taro-docs.jd.com/taro/docs/README/
因为前几天更新过3.0的版本了 所以 说关于3.0的
taro是制作微信小程序,h5等有效的开发工具 对于react人员是比较友好的
首先,你需要使用 npm 或者 yarn 全局安装 @tarojs/cli
这东西安装一次就行了 全局的
使用 npm 安装 CLI
$ npm install -g @tarojs/cli
OR 使用 yarn 安装 CLI
$ yarn global add @tarojs/cli
OR 安装了 cnpm,使用 cnpm 安装 CLI
$ cnpm install -g @tarojs/cli
三个命令随便选
安装完成之后看看 成功了吗
npm info @tarojs/cli ----查看版本信息
$ taro init myApp 创建你的项目
按照步骤走就行
安装完之后 cnpm i 或者 yarn 下载依赖 也就是node包
我们平时使用的hook还是从react中引入
例如:
import { useState, useEffect } from ‘react’
但是 这里面只能用 View Text 所以以下是引用:
import { View, Text, Button } from ‘@tarojs/components’
import Taro from ‘@tarojs/taro’
跳路由例子:
也能传值
Taro.navigateTo({
url: ‘/pages/index/index?a=1&b=2’,
success:() => {
console.log(‘成功了’)
}
})
取值的话 就直接
getCurrentInstance().router.params
请求数据的话 就用 request
aro.request({ method: ‘POST’, url: api.home, })
在 app.config.js中配置路由
pages: [
‘pages/home/index’,
‘pages/index/index’
],
谁在上面 谁先显示
下面是关于tabBar的
// tabBar:{
// list:[
// {
// pagePath:‘pages/home/index’,
// text:‘Home’
// },
// {
// pagePath:‘pages/index/index’,
// text:‘其他’
// },
// ]
这里面是公共的样式
window: {
backgroundTextStyle: ‘light’,
navigationBarBackgroundColor: ‘#fff’,
navigationBarTitleText: ‘WeChat’,
navigationBarTextStyle: ‘black’
}
// },