File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -144,9 +144,9 @@ const foo = (
144144绑定的值应该像这样: ` (item, index) in list `
145145- ` list ` : 遍历的目标数组
146146- ` item ` : 当前的值
147- - ` index ` : 当前的索引
147+ - ` index ` : 当前的索引 (可选)
148148
149- 提示: ` index ` 是可选的, 如果不需要 ` index ` 可以这样用: ` item in list `
149+ ** 提示 ** : 如果你在项目中使用了 [ ** ESLint ** ] ( https://eslint.org ) ,也许会提示你: ` item ` 和 ` index ` 是未定义的变量,请安装 [ ` eslint-plugin-react-directives ` ] ( https://github.com/peakchen90/eslint-plugin-react-directives ) 来解决这个问题
150150
151151** 例子:**
152152``` jsx harmony
@@ -305,7 +305,7 @@ class Foo extends React.Component {
305305}
306306```
307307
308- 如果 ` x-model ` 的值是一个对象上的属性,那么当表单元素更新时将创建一个新对象,并合并对象上旧的属性值 ,比如:
308+ 如果 ` x-model ` 的值是一个对象上的属性,那么当更新时将创建一个新对象,并将对象上旧的属性值合并到新对象上 ,比如:
309309``` jsx harmony
310310class Foo extends React .Component {
311311 constructor (props ) {
@@ -360,6 +360,9 @@ class Foo extends React.Component {
360360```
361361
362362当然也可以使用 ` useState ` hook 方式:
363+
364+ ** 提示** : 如果你在项目中使用了 [ ** ESLint** ] ( https://eslint.org ) ,也许会提示你 ` setData ` 是一个从未使用的变量,请安装 [ ` eslint-plugin-react-directives ` ] ( https://github.com/peakchen90/eslint-plugin-react-directives ) 来解决这个问题
365+
363366``` jsx harmony
364367function Foo () {
365368 const [data , setData ] = useState (0 );
Original file line number Diff line number Diff line change @@ -145,9 +145,11 @@ The `x-for` is used to traverse arrays to generate elements.
145145The value should like: ` (item, index) in list `
146146- ` list ` : array for traversal
147147- ` item ` : current value
148- - ` index ` : current index
148+ - ` index ` : current index (optional)
149+
150+ ** Note** : If you use [ ** ESLint** ] ( https://eslint.org ) , you may receive an error that ` item ` and ` index ` are undeclared variables.
151+ Please install [ ` eslint-plugin-react-directives ` ] ( https://github.com/peakchen90/eslint-plugin-react-directives ) plugin to solve it.
149152
150- Note: ` index ` is optional, no ` index ` can be replaced with ` item in list `
151153
152154** Example:**
153155``` jsx harmony
@@ -361,6 +363,10 @@ class Foo extends React.Component {
361363```
362364
363365Of course you can also use ** ` useState ` ** hook
366+
367+ ** Note** : If you use [ ** ESLint** ] ( https://eslint.org ) , you may receive an error that ` setState ` is defined but never used.
368+ Please install [ ` eslint-plugin-react-directives ` ] ( https://github.com/peakchen90/eslint-plugin-react-directives ) plugin to solve it.
369+
364370``` jsx harmony
365371function Foo () {
366372 const [data , setData ] = useState (0 );
You can’t perform that action at this time.
0 commit comments