Skip to content

Commit bcef5ae

Browse files
authored
Merge pull request #997 from reactnativecn/auto-translate-20260215-batch
自动翻译:批量更新文档(忽略下划线)
2 parents f3be27b + 76e40cd commit bcef5ae

10 files changed

+766
-217
lines changed
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: getting-started-without-a-framework
3-
title: Get Started Without a Framework
3+
title: 不使用框架开始开发
44
hide_table_of_contents: true
55
---
66

@@ -13,45 +13,45 @@ import RemoveGlobalCLI from './\_remove-global-cli.md';
1313

1414
<PlatformSupport platforms={['android', 'ios', 'macOS', 'tv', 'watchOS', 'web', 'windows', 'visionOS']} />
1515

16-
If you have constraints that are not served well by a [Framework](/architecture/glossary#react-native-framework), or you prefer to write your own Framework, you can create a React Native app without using a Framework.
16+
如果[框架](/architecture/glossary#react-native-framework)无法很好地满足你的需求,或者你更倾向于自己编写框架,那么你可以在不使用框架的情况下创建 React Native 应用。
1717

18-
To do so, you'll first need to [set up your environment](set-up-your-environment). Once you're set up, continue with the steps below to create an application and start developing.
18+
为此,你首先需要[搭建开发环境](set-up-your-environment)。环境准备就绪后,继续按以下步骤创建应用并开始开发。
1919

20-
### Step 1: Creating a new application
20+
### 第 1 步:创建新项目
2121

2222
<RemoveGlobalCLI />
2323

24-
You can use [React Native Community CLI](https://github.com/react-native-community/cli) to generate a new project. Let's create a new React Native project called "AwesomeProject":
24+
你可以使用 [React Native Community CLI](https://github.com/react-native-community/cli) 来生成新项目。让我们创建一个名为 "AwesomeProject" 的 React Native 项目:
2525

2626
```shell
2727
npx @react-native-community/cli@latest init AwesomeProject
2828
```
2929

30-
This is not necessary if you are integrating React Native into an existing application, or if you've installed [Expo](https://docs.expo.dev/bare/installing-expo-modules/) in your project, or if you're adding Android support to an existing React Native project (see [Integration with Existing Apps](integration-with-existing-apps.md)). You can also use a third-party CLI to set up your React Native app, such as [Ignite CLI](https://github.com/infinitered/ignite).
30+
如果你要将 React Native 集成到现有应用中,或者已经在项目中安装了 [Expo](https://docs.expo.dev/bare/installing-expo-modules/),又或者要为现有的 React Native 项目添加 Android 支持(参见[集成到现有应用](integration-with-existing-apps.md)),则无需执行此步骤。你也可以使用第三方 CLI 工具来创建 React Native 应用,例如 [Ignite CLI](https://github.com/infinitered/ignite)
3131

3232
:::info
3333

34-
If you are having trouble with iOS, try to reinstall the dependencies by running:
34+
如果你在 iOS 上遇到问题,可以尝试重新安装依赖:
3535

36-
1. `cd ios` to navigate to the `ios` folder.
37-
2. `bundle install` to install [Bundler](https://bundler.io/)
38-
3. `bundle exec pod install` to install the iOS dependencies managed by CocoaPods.
36+
1. 执行 `cd ios` 进入 `ios` 目录。
37+
2. 执行 `bundle install` 安装 [Bundler](https://bundler.io/)
38+
3. 执行 `bundle exec pod install` 安装由 CocoaPods 管理的 iOS 依赖。
3939

4040
:::
4141

42-
#### [Optional] Using a specific version or template
42+
#### [可选] 使用特定版本或模板
4343

44-
If you want to start a new project with a specific React Native version, you can use the `--version` argument:
44+
如果你想使用特定版本的 React Native 来创建项目,可以使用 `--version` 参数:
4545

4646
```shell
4747
npx @react-native-community/cli@X.XX.X init AwesomeProject --version X.XX.X
4848
```
4949

50-
You can also start a project with a custom React Native template with the `--template` argument, read more [here](https://github.com/react-native-community/cli/blob/main/docs/init.md#initializing-project-with-custom-template).
50+
你也可以使用 `--template` 参数基于自定义模板创建项目,详情请参阅[这里](https://github.com/react-native-community/cli/blob/main/docs/init.md#initializing-project-with-custom-template)
5151

52-
### Step 2: Start Metro
52+
### 第 2 步:启动 Metro
5353

54-
[**Metro**](https://metrobundler.dev/) is the JavaScript build tool for React Native. To start the Metro development server, run the following from your project folder:
54+
[**Metro**](https://metrobundler.dev/) React Native 的 JavaScript 构建工具。要启动 Metro 开发服务器,请在项目目录中执行以下命令:
5555

5656
<Tabs groupId="package-manager" queryString defaultValue={constants.defaultPackageManager} values={constants.packageManagers}>
5757
<TabItem value="npm">
@@ -71,12 +71,12 @@ yarn start
7171
</Tabs>
7272

7373
:::note
74-
If you're familiar with web development, Metro is similar to bundlers such as Vite and webpack, but is designed end-to-end for React Native. For instance, Metro uses [Babel](https://babel.dev/) to transform syntax such as JSX into executable JavaScript.
74+
如果你熟悉 Web 开发,Metro 类似于 Vite webpack 等打包工具,但它是专为 React Native 端到端设计的。例如,Metro 使用 [Babel](https://babel.dev/) JSX 等语法转换为可执行的 JavaScript
7575
:::
7676

77-
### Step 3: Start your application
77+
### 第 3 步:启动应用
7878

79-
Let Metro Bundler run in its own terminal. Open a new terminal inside your React Native project folder. Run the following:
79+
Metro Bundler 在自己的终端窗口中继续运行。在 React Native 项目目录下打开一个新的终端,然后执行以下命令:
8080

8181
<Tabs groupId="package-manager" queryString defaultValue={constants.defaultPackageManager} values={constants.packageManagers}>
8282
<TabItem value="npm">
@@ -95,26 +95,28 @@ yarn android
9595
</TabItem>
9696
</Tabs>
9797

98-
If everything is set up correctly, you should see your new app running in your Android emulator shortly.
98+
如果一切配置正确,你应该很快就能在 Android 模拟器中看到新应用运行起来了。
9999

100-
This is one way to run your app - you can also run it directly from within Android Studio.
100+
这只是运行应用的方式之一——你也可以直接从 Android Studio 中运行。
101101

102-
> If you can't get this to work, see the [Troubleshooting](troubleshooting.md) page.
102+
:::tip
103+
如果无法正常运行,请参阅[问题排查](troubleshooting.md)页面。
104+
:::
103105

104-
### Step 4: Modifying your app
106+
### 第 4 步:修改你的应用
105107

106-
Now that you have successfully run the app, let's modify it.
108+
既然你已经成功运行了应用,接下来让我们来修改它。
107109

108-
- Open `App.tsx` in your text editor of choice and edit some lines.
109-
- Press the <kbd>R</kbd> key twice or select `Reload` from the Dev Menu (<kbd>Ctrl</kbd> + <kbd>M</kbd>) to see your changes!
110+
- 用你喜欢的文本编辑器打开 `App.tsx`,编辑其中的代码。
111+
- 按两下 <kbd>R</kbd> 键或者在开发者菜单(<kbd>Ctrl</kbd> + <kbd>M</kbd>)中选择 `Reload` 来查看修改效果!
110112

111-
### That's it!
113+
### 大功告成!
112114

113-
Congratulations! You've successfully run and modified your first barebone React Native app.
115+
恭喜!你已经成功运行并修改了你的第一个 React Native 应用。
114116

115117
<center><img src="/docs/assets/GettingStartedCongratulations.png" width="150"></img></center>
116118

117-
### Now what?
119+
### 接下来做什么?
118120

119-
- If you want to add this new React Native code to an existing application, check out the [Integration guide](integration-with-existing-apps.md).
120-
- If you're curious to learn more about React Native, check out the [Introduction to React Native](getting-started).
121+
- 如果你想将 React Native 代码集成到现有应用中,请查阅[集成指南](integration-with-existing-apps.md)
122+
- 如果你想进一步了解 React Native,请查阅 [React Native 简介](getting-started)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: global-PerformanceResourceTiming
3+
title: PerformanceResourceTiming
4+
---
5+
6+
全局 [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming) 类,遵循 Web 规范定义。
7+
8+
:::warning 部分支持
9+
10+
React Native 仅实现了以下 `PerformanceResourceTiming` 属性:
11+
12+
- `fetchStart`
13+
- `requestStart`
14+
- `connectStart`
15+
- `connectEnd`
16+
- `responseStart`
17+
- `responseEnd`
18+
- `responseStatus`
19+
- `contentType`
20+
- `encodedBodySize`
21+
- `decodedBodySize`
22+
23+
:::
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
id: global-intersectionobserver
3+
title: IntersectionObserver 🧪
4+
---
5+
6+
import CanaryAPIWarning from './\_canary-channel-api-warning.mdx';
7+
8+
<CanaryAPIWarning />
9+
10+
全局 [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) 接口,遵循 Web 规范定义。它提供了一种异步观察目标元素与祖先元素或顶层文档视口交叉状态变化的方法。
11+
12+
---
13+
14+
# 参考
15+
16+
## 构造函数
17+
18+
### `IntersectionObserver()`
19+
20+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver)
21+
22+
创建一个新的 `IntersectionObserver` 对象,当检测到目标元素的可见性超过一个或多个 `threshold``rnRootThreshold` 值时,会执行指定的回调函数。
23+
24+
```ts
25+
new IntersectionObserver(callback, options?)
26+
```
27+
28+
#### 参数
29+
30+
**`callback`**
31+
32+
当目标元素的可见比例超过阈值时调用的函数。回调接收两个参数:
33+
34+
- `entries`:一个 [`IntersectionObserverEntry`](global-intersectionobserverentry) 对象数组,每个对象代表一个被超过的阈值——目标元素的可见程度相对于该阈值指定的百分比有所增加或减少。
35+
- `observer`:调用该回调的 `IntersectionObserver` 实例。
36+
37+
**`options`**(可选)
38+
39+
一个可选对象,包含以下属性:
40+
41+
| 名称 | 类型 | 说明 |
42+
| -------------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43+
| `root` | [Element](element-nodes) \| null | 目标的祖先元素,其边界矩形将被视为视口。如果未指定或为 `null`,则默认为根视口。 |
44+
| `rootMargin` | string | 计算交叉时添加到根边界框的偏移量字符串。默认为 `"0px 0px 0px 0px"`。 |
45+
| `threshold` | number \| number[] | 一个数值或数值数组(范围 0.0 到 1.0),指定目标元素交叉面积与总边界框面积的比值。如果未设置 `rnRootThreshold`,则默认为 `[0]`。 |
46+
| `rnRootThreshold` ⚠️ | number \| number[] | **React Native 特有。** 一个数值或数值数组(范围 0.0 到 1.0),指定交叉面积与根元素总面积的比值。 |
47+
48+
## 实例属性
49+
50+
### `root`
51+
52+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root)。
53+
54+
用于进行交叉测试时作为边界框的元素或文档。
55+
56+
### `rootMargin`
57+
58+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin)。
59+
60+
计算交叉时应用于根边界框的偏移矩形。
61+
62+
### `rnRootThresholds` ⚠️
63+
64+
:::warning 非标准
65+
这是 React Native 特有的扩展。
66+
:::
67+
68+
一个按升序排列的根阈值列表,其中每个阈值是交叉面积与指定根视图(默认为视口)边界框面积的比值。
69+
70+
当观察目标的 `rnRootThresholds``thresholds` 中指定的任一阈值被超过时,会生成通知。
71+
72+
```ts
73+
get rnRootThresholds(): ReadonlyArray<number> | null;
74+
```
75+
76+
### `thresholds`
77+
78+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/thresholds)。
79+
80+
一个按升序排列的阈值列表,其中每个阈值是交叉面积与观察目标边界框面积的比值。
81+
82+
当观察目标的 `rnRootThresholds``thresholds` 中指定的任一阈值被超过时,会生成通知。
83+
84+
## 实例方法
85+
86+
### `disconnect()`
87+
88+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/disconnect)。
89+
90+
停止 `IntersectionObserver` 对象对所有目标的观察。
91+
92+
### `observe()`
93+
94+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/observe)。
95+
96+
告知 `IntersectionObserver` 开始观察指定的目标元素。
97+
98+
### `takeRecords()`
99+
100+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/takeRecords)。
101+
102+
返回所有已观察目标的 `IntersectionObserverEntry` 对象数组。
103+
104+
### `unobserve()`
105+
106+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/unobserve)。
107+
108+
告知 `IntersectionObserver` 停止观察指定的目标元素。
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
id: global-intersectionobserverentry
3+
title: IntersectionObserverEntry 🧪
4+
---
5+
6+
import CanaryAPIWarning from './\_canary-channel-api-warning.mdx';
7+
8+
<CanaryAPIWarning />
9+
10+
[`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) 接口,遵循 Web 规范定义。它描述了目标元素与其根容器在特定时刻的交叉状态。
11+
12+
`IntersectionObserverEntry` 的实例通过 [`IntersectionObserver`](global-intersectionobserver) 回调函数的 `entries` 参数传递。
13+
14+
---
15+
16+
# 参考
17+
18+
## 实例属性
19+
20+
### `boundingClientRect`
21+
22+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry/boundingClientRect)
23+
24+
返回目标元素的边界矩形,类型为 `DOMRectReadOnly`
25+
26+
### `intersectionRatio`
27+
28+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry/intersectionRatio)
29+
30+
返回 `intersectionRect``boundingClientRect` 的面积比值。
31+
32+
### `intersectionRect`
33+
34+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry/intersectionRect)
35+
36+
返回表示目标可见区域的 `DOMRectReadOnly`
37+
38+
### `isIntersecting`
39+
40+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry/isIntersecting)
41+
42+
一个布尔值,当目标元素与交叉观察器的根元素相交时为 `true`。如果为 `true`,表示 `IntersectionObserverEntry` 描述的是进入交叉状态的转换;如果为 `false`,表示从交叉状态变为非交叉状态。
43+
44+
### `rnRootIntersectionRatio` ⚠️
45+
46+
:::warning 非标准
47+
这是 React Native 特有的扩展。
48+
:::
49+
50+
返回 `intersectionRect``rootBounds` 的面积比值。
51+
52+
```ts
53+
get rnRootIntersectionRatio(): number;
54+
```
55+
56+
这与 `intersectionRatio` 类似,但计算的是相对于根元素边界框的比值,而非目标元素的边界框。这对应于 `rnRootThreshold` 选项,允许你判断根区域被目标元素覆盖的百分比。
57+
58+
### `rootBounds`
59+
60+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry/rootBounds)
61+
62+
返回交叉观察器根元素的 `DOMRectReadOnly`
63+
64+
### `target`
65+
66+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry/target)
67+
68+
与根元素交叉状态发生变化的 `Element`
69+
70+
### `time`
71+
72+
参见 [MDN 文档](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry/time)
73+
74+
一个 `DOMHighResTimeStamp`,表示相对于 `IntersectionObserver` 时间原点的交叉记录时间。

0 commit comments

Comments
 (0)