Taro
sonder 大杯

taro taro-ui

  • 安装
1
2
3
4
5
6
<!--使用 npm 安装 CLI-->
npm install -g @tarojs/cli
<!--OR 使用 yarn 安装 CLI-->
yarn global add @tarojs/cli
<!--OR 安装了 cnpm,使用 cnpm 安装 CLI-->
cnpm install -g @tarojs/cli
  • 使用
1
taro init myApp

==ps:Taro会默认安装所需依赖,但如果安装失败,可以自行安装,直接 yarn==

  • 运行
1
2
3
4
<!--这里是运行在小程序-->
yarn dev:weapp
/
npm run dev:weapp
  • 以下是各个终端运行
终端 命令
百度小程序 yarn dev:swan/npm run dev:swan
支付宝小程序 yarn dev:alipay/npm run dev:alipay

==打包就是把dev改成build==

request请求

1
2
3
4
5
componentDidMount(){
Taro.request({
url:''//必须
}).then(res=>console.log(res))
}

taro-ui

  • 安装
1
npm i taro-ui
  • 使用
1
2
3
4
5
// page.js
import { AtButton } from 'taro-ui'
// 除了引入所需的组件,还需要手动引入组件样式
// app.js
import 'taro-ui/dist/style/index.scss' // 全局引入一次即可
  • ui组件示例
1
2
3
//pages下的index.jsx
import { AtButton } from 'taro-ui'
<AtButton type='primary'>按钮文案</AtButton>
  • 本文标题:Taro
  • 本文作者:sonder
  • 创建时间:2019-08-20 22:23:13
  • 本文链接:https://sonderss.github.io/2019/08/20/Taro/
 评论