-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
layout: post | ||
catalog: true | ||
tags: | ||
- Taro | ||
|
||
--- | ||
|
||
# 1. 概念 | ||
|
||
Taro 在组件、API、路由等规范上,遵循微信小程序规范,所以在 Taro 中使用 React 和开发者熟悉的 Web 端有一些差异 | ||
|
||
因为在 Taro 3 中开发者使用的是真实的 React,React 的 API 如 `Component`、`useState`、`useEffect` 等都需要从 React 包中获取。 | ||
|
||
从 Taro v3.5 开始,Taro 将默认使用 React 18 版本 | ||
|
||
``` | ||
// 从 'react' 包中获取 React API | ||
import React, { Component, useState, useEffect } from 'react' | ||
``` | ||
|
||
UI组件使用Taro UI | ||
# 2. 入口组件和页面组件 | ||
|
||
因为 Taro 遵循小程序的路由规范,所以引入了入口组件和页面组件的概念,分别对应小程序规范的入口组件 `app` 和页面组件 `page`。 | ||
|
||
一个 Taro 应用由一个入口组件和至少一个页面组件所组成。 |