Elliot Yang 的动态

动态详情

返回列表
Elliot Yang

Elliot Yang

How to use React label element?

If you try to render a <label> element bound to a text input using the standard for attribute, then it produces HTML missing that attribute and prints a warning to the console.

js
1<label for={'user'}>{'User'}</label>
2<input type={'text'} id={'user'} />

Since for is a reserved keyword in JavaScript, use htmlFor instead.

js
1<label htmlFor={'user'}>{'User'}</label>
2<input type={'text'} id={'user'} />
浏览:194点赞:0