React将元素添加到元素

时间:2017-06-12 14:21:30

标签: reactjs react-jsx preact

我正在尝试为元素添加一个类名,但它不起作用。我错过了JSX组件的东西吗?

import { h, Component } from 'preact';
import { Link } from 'preact-router/match';
import style from './style';

export default class Header extends Component {
        render() {
                return (
                        <header class={style.header}>
                                <h1>Lancaster County Apple Corps</h1>
                                <img class="site-icon" src="assets/icons/icon-128x128.png" alt="LCAC site icon" />
                                <nav>
                                        <Link activeClassName={style.active} href="/">Home</Link>
                                        <Link activeClassName={style.active} href="/benefits">Benefits</Link>
                                        <Link activeClassName={style.active} href="/cost">Cost</Link>
                                        <Link activeClassName={style.active} href="/memberForm">Member Form</Link>
                                        <Link activeClassName={style.active} href="/meetingNotes">Meeting Notes</Link>
                                        <Link activeClassName={style.active} href="/links">Links</Link>
                                </nav>
                        </header>
                );
        }
}

2 个答案:

答案 0 :(得分:2)

它应该是className而不是classhttps://facebook.github.io/react/docs/jsx-in-depth.html

答案 1 :(得分:0)

假设您的样式中有.header .site-icon { width: 45px; },如上所述,您可以尝试<header className="site-icon">吗?