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

相关文章:

  • 2021-07-01
  • 2022-12-23
  • 2021-04-04
  • 2021-05-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-10-31
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-09-29
  • 2021-07-07
  • 2021-11-21
相关资源
相似解决方案