2017-07-05 59 views
0

尝试通过反应组件内部的变量设置字体颜色,但我<span>给出错误:字体颜色反应

Type '{ style: "color:yellow"; }' is not assignable to type 'HTMLProps<HTMLSpanElement>' 

黄色是只是为了测试,我将与{颜色替换} 到底。

import * as React from 'react'; 

    export interface SkillListItemProps { 
     name: string 
     color: string 
     // Icons: 
    } 

    interface SkillListItemState{ 
    } 

    export class SkillListItem extends React.Component<SkillListItemProps,SkillListItemState>{ 
     public render(): JSX.Element{ 
      const {name, color} = this.props; 
     return (
      <div className="SkillListItem"> 
       <span style="color:yellow">{name}</span> 
      </div> 
     ) 
     } 
    } 

回答