javascript - 使用情感样式列表元素
问题描述
我正在尝试react
使用emotion
我想让我的ul
和li
元素不受子弹的影响。
我正在关注Emotion 的这个文档。
这是他们的例子:
import styled from '@emotion/styled'
const Child = styled.div`
color: red;
`
const Parent = styled.div`
${Child} {
color: green;
}
`
render(
<div>
<Parent>
<Child>green</Child>
</Parent>
<Child>red</Child>
</div>
)
这是我的尝试。
import React from 'react';
import styled from '@emotion/styled'
class Budget extends React.Component {
state = {
studentLoanPayment: 0,
};
handleInputChange = event => {
const { name, value } = event.target;
console.log(name, value)
this.setState({ [name]: value });
};
const Li = styled.li({
color: 'red'
})
render() {
但是,我在
如何定位常见的 HTML 元素(unexpected token
如, , , ?li
const li = ...
ul
li
p
label
解决方案
您的语法不正确,应该是:
const Li = styled.li`
color: red;
`
推荐阅读
- python - Python 将类型提示字符串表示(从 docstring)转换为实际的类型/键入对象
- python - 用 pandas 的其他行中的值填充一列
- database - ORA-02018: 同名的数据库链接具有打开的连接
- ssl - 让我们加密。三个域之一的悬而未决的挑战
- json - Insomnia - 断言键为空值的对象
- c++ - 尽管我将 target_compile_features 设置为 cxx_std_17,但 CMake 并未将编译器选项 -std 设置为 gnu17 或 c++17
- angular - 需要添加具有相同功能的不同数据的第 N 个下拉列表
- javascript - 将对象内的对象数组作为多个对象 JavaScript
- python - Sub-dictionary from dictionary. Create another dictionary with dict comprehension, or delete keys from a copy of the original dictionary
- sql - 在雪花中使用 regexp_substr 提取数字