Skip to content

Commit 2d7c183

Browse files
committed
update readme
1 parent 7612dff commit 2d7c183

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

README.ZH-CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- [开始使用](#toc-usage)
1414
- [安装](#toc-installation)
1515
- [添加配置 `.babelrc`](#toc-configuring)
16-
- [或使用插件options](#toc-or-use-options)
16+
- [插件options](#toc-plugin-options)
1717
- [指令](#toc-directives)
1818
- [x-if](#toc-directives-x-if)
1919
- [x-else-if 和 x-else](#toc-directives-x-else-if-and-x-else)
@@ -51,7 +51,7 @@ yarn add --dev babel-plugin-react-directives
5151
}
5252
```
5353

54-
### <span id="toc-or-use-options">或使用插件options (<a target="_blank" href="https://babeljs.io/docs/en/plugins#plugin-options">配置说明</a>)</span>
54+
### <span id="toc-plugin-options">插件options</span>
5555

5656
```json
5757
{
@@ -226,7 +226,7 @@ const foo = (
226226

227227
### <span id="toc-directives-x-model">x-model</span>
228228
`x-model` 是类似于 vue `v-model` 的语法糖,使用时绑定一个值到表单元素的 `value` prop 上,在表单元素更新时自动更新状态。
229-
通过调用 [resolveValue 方法](./runtime/resolve-value.js) 获取更新的值(如果第一个参数 `arg` 不为空,且 `arg.target` 是一个对象,返回 `arg.target.value`,否则返回 `arg`
229+
通过调用 [resolveValue 方法](./runtime/resolve-value.js) 获取更新的值(如果第一个参数 `arg` 不为空,且 `arg.target` 是一个 HTMLElement, 返回 `arg.target.value`,否则返回 `arg`
230230

231231
**例子:**
232232
```jsx harmony
@@ -374,7 +374,7 @@ class Foo extends React.Component {
374374
```
375375

376376
### <span id="toc-directives-x-model-hook">x-model-hook</span>
377-
`x-model-hook``x-model` 非常相似,区别在于 `x-model-hook` 用于 **useState hook function**,而 `x-model` 用于 **class component**
377+
`x-model-hook``x-model` 非常相似,区别在于 `x-model-hook` 用于使用了 **useState hook** 的函数组件,而 `x-model` 用于 class component
378378

379379
**例子:**
380380
```jsx harmony

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A babel plugin that provides some directives for react(any JSX), similar to dire
1414
- [Usage](#toc-usage)
1515
- [Installation](#toc-installation)
1616
- [Configuring via `.babelrc`](#toc-configuring)
17-
- [Or use options](#toc-or-use-options)
17+
- [Plugin options](#toc-plugin-options)
1818
- [Directives](#toc-directives)
1919
- [x-if](#toc-directives-x-if)
2020
- [x-else-if and x-else](#toc-directives-x-else-if-and-x-else)
@@ -52,7 +52,7 @@ yarn add --dev babel-plugin-react-directives
5252
}
5353
```
5454

55-
### <span id="toc-or-use-options">Or use options (<a target="_blank" href="https://babeljs.io/docs/en/plugins#plugin-options">Babel plugin options</a>)</span>
55+
### <span id="toc-or-use-options">Plugin options</span>
5656

5757
```json
5858
{
@@ -68,7 +68,7 @@ yarn add --dev babel-plugin-react-directives
6868
}
6969
```
7070

71-
- `prefix`: JSX props prefix for directives. Default: "x", usage example: `x-if`
71+
- `prefix`: JSX props prefix for directives. Default: "x", example usage: `x-if`
7272
- `pragmaType`: Help internal to correctly identify some syntax, such as hooks. Default: "React"
7373

7474
## <span id="toc-directives">Directives</span>
@@ -120,7 +120,7 @@ const foo = (
120120
```
121121

122122
### <span id="toc-directives-x-show">x-show</span>
123-
The `x-show` controls the display or hiding of elements by the `display` of the `style` prop. If the `x-show` value is **falsy**, will set `style.display = "none"`, otherwise do nothing.
123+
The `x-show` controls the display or hiding of elements through the `display` of the `style` prop. If the `x-show` value is **falsy**, will set `style.display = "none"`, otherwise do nothing.
124124

125125

126126
**Example:**
@@ -229,7 +229,7 @@ const foo = (
229229

230230
### <span id="toc-directives-x-model">x-model</span>
231231
The `x-model` is a syntax sugar similar to vue `v-model`, which binds a state to the `value` prop of the **form element** and automatically updates the state when the element is updated.
232-
It resolves the updated value by calling the [resolveValue method](./runtime/resolve-value.js) (If the first argument `arg` is non-empty, and `arg.target` is an object, return `arg.target.value`, otherwise return `arg`).
232+
It resolves the updated value by calling the [resolveValue method](./runtime/resolve-value.js) (If the first argument `arg` is non-null, and `arg.target` is a HTMLElement, return `arg.target.value`, otherwise return `arg`).
233233

234234
**Example:**
235235
```jsx harmony
@@ -377,7 +377,7 @@ class Foo extends React.Component {
377377
```
378378

379379
### <span id="toc-directives-x-model-hook">x-model-hook</span>
380-
The `x-model-hook` is similar to the `x-model`, the difference is that the `x-model-hook` is used in the **useState hook function**, and the `x-model` is used in the **class component**.
380+
The `x-model-hook` is similar to the `x-model`, the difference is that the `x-model-hook` is used in the function component with **useState hook**, and the `x-model` is used in the class component.
381381

382382
**Example:**
383383
```jsx harmony
@@ -427,7 +427,6 @@ const foo = <div className={classNames({ abc: true, def: false })}>
427427
**Note**: `classNames` method references [runtime/classnames.js](./runtime/classnames.js).
428428

429429
Of course, it will also merge other `className` props, for example:
430-
**Example:**
431430
```jsx harmony
432431
const foo = <div x-class={{ abc: true, def: false }} className="xyz">
433432
```
@@ -438,7 +437,7 @@ const foo = <div className={classNames(["xyz", { abc: true, def: false }])}>
438437
// className="xyz abc"
439438
```
440439

441-
The `x-class` can also be used with [css-modules](https://github.com/css-modules/css-modules), for example:
440+
The `x-class` can also be used with [css-modules](https://github.com/css-modules/css-modules), the usage is as follows:
442441
```jsx harmony
443442
import styles from './style.css';
444443

0 commit comments

Comments
 (0)