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