1.7 KiB
1.7 KiB
id | title | challengeType | isRequired | videoUrl | localeTitle |
---|---|---|---|---|---|
5a24c314108439a4d4036160 | Define an HTML Class in JSX | 6 | false | 在JSX中定义HTML类 |
Description
class
来定义HTML类。这是因为class
是JavaScript中的保留字。相反,JSX使用className
。事实上,JSX中所有HTML属性和事件引用的命名约定都变成了camelCase。例如,JSX中的单击事件是onClick
,而不是onclick
。同样, onchange
变为onChange
。虽然这是一个微妙的差异,但重要的是要记住前进。 Instructions
myDiv
类myDiv
JSX代码中提供的div
。 Tests
tests:
- text: 常量<code>JSX</code>应该返回一个<code>div</code>元素。
testString: 'assert.strictEqual(JSX.type, "div", "The constant <code>JSX</code> should return a <code>div</code> element.");'
- text: <code>div</code>有一类<code>myDiv</code> 。
testString: 'assert.strictEqual(JSX.props.className, "myDiv", "The <code>div</code> has a class of <code>myDiv</code>.");'
Challenge Seed
const JSX = (
<div>
<h1>Add a class to this div</h1>
</div>
);
After Test
console.info('after the test');
Solution
// solution required