1-1 安装

  1. # 使用 npm 安装 CLI
  2. $ npm install -g @tarojs/cli
  3. # OR 使用 yarn 安装 CLI
  4. $ yarn global add @tarojs/cli
  5. # OR 安装了 cnpm,使用 cnpm 安装 CLI
  6. $ cnpm install -g @tarojs/cli
  1. 可以使用 npm info 查看 Taro 版本信息,在这里你可以看到当前最新版本
  2. npm info @tarojs/cli

1-2 项目初始化

image.png

  1. taro init xxx(name)

1-3 安装依赖

  1. # 进入项目根目录
  2. $ cd myApp
  3. # 使用 yarn 安装依赖
  4. $ yarn
  5. # OR 使用 cnpm 安装依赖
  6. $ cnpm install
  7. # OR 使用 npm 安装依赖
  8. $ npm install

1-4 运行

image.png
image.png

  1. # h5
  2. # yarn
  3. $ yarn dev:h5
  4. $ yarn build:h5
  5. # npm script
  6. $ npm run dev:h5
  7. $ npm run build:h5
  8. # 仅限全局安装
  9. $ taro build --type h5 --watch
  10. $ taro build --type h5
  11. # npx 用户也可以使用
  12. $ npx taro build --type h5 --watch
  13. $ npx taro build --type h5