React组件封装

//内部封装
import React from ‘react’

import ‘./index.less’

const List = ({
listClick,
list,
listStyle
}) => {
return (
list && list.map(e => (
< div
onClick={listClick.bind(this, e)}
style={listStyle}
>{e.name}
))

)
}
export default List

//外部调用
<List
listClick={(e) => { console.log(e) }}
list={EmotionLabel}
listStyle={{ height: 50, width: 50, background: ‘red’ }}
/>

猜你喜欢

转载自blog.csdn.net/weixin_45537044/article/details/107771203