JavaScript风格,如何应用两个类
让我描述一下我的问题: 我有一个反应组件,如下所示JavaScript风格,如何应用两个类,javascript,reactjs,Javascript,Reactjs,让我描述一下我的问题: 我有一个反应组件,如下所示 import React from 'react'; class Question extends React.Component{ render(){ return <div className="view fourth-effect"> <a href={this.props.link} title="Full Image"> &l
import React from 'react';
class Question extends React.Component{
render(){
return <div className="view fourth-effect">
<a
href={this.props.link}
title="Full Image">
<img src={this.props.image}/>
</a>
<div className="mask"></div>
<span className='title'>{this.props.title}</span>
<span className='owner'>{this.props.owner}</span>
</div>
}
}
Question.propTypes = {
title: React.PropTypes.string.isRequired,
owner: React.PropTypes.string.isRequired,
image: React.PropTypes.string.isRequired,
link : React.PropTypes.string.isRequired
};
Question.defaultProps = {
title: 'none',
owner: '-',
image: '-',
link : '-'
};
export default Question
从“React”导入React;
类问题扩展了React.Component{
render(){
返回
{this.props.title}
{this.props.owner}
}
}
问题.propTypes={
标题:React.PropTypes.string.isRequired,
所有者:React.PropTypes.string.isRequired,
image:React.PropTypes.string.isRequired,
链接:React.PropTypes.string.isRequired
};
问题.defaultProps={
标题:“无”,
所有者:'-',
图片:'-',
链接:'-'
};
导出默认问题
对于样式,我使用css文件。现在我很有兴趣在React中使用内联样式,但我一直坚持
如何像在css中一样为React元素应用两个类
<div className="view fourth-effect">
只是使用JS对象,应该是这样的
<div style={Style.question}> /*JS style object*/
/*JS样式对象*/
如何在React中使用内联样式组合两个类
提前谢谢 样式属性也接受数组。因此,您可以:
也许你会感到不安。它允许使用:悬停
,:焦点
,:活动
伪选择器,还可以自动添加供应商prefixes@imkost,谢谢,我听说过镭,但现在我想总结一下我对React和JS Core的了解