1.安裝
(1)安裝腳手架
npm install -g @tarojs/cli taro init myApp
(2)H5端運行
npm run dev:h5 taro build --type h5 --watch
(3)微信小程序端運行
npm run dev:weapp taro build --type weapp --watch
2.語法
import Taro, { Component } from '@tarojs/taro' import Index from './pages/index' import './app.scss' class App extends Component { // 項目配置 config = { pages: [ 'pages/index/index' ], window: { backgroundTextStyle: 'light', navigationBarBackgroundColor: '#fff', navigationBarTitleText: 'WeChat', navigationBarTextStyle: 'black' } } componentWillMount () {} componentDidMount () {} componentDidShow () {} componentDidHide () {} render () { return ( <Index /> ) } }
3.demo