我尝试将onChange设置为更改图标。
但这不起作用。
前端:React
css:semantic-ui-react
constructor(props: {}) {
super(props);
this.state = {
icon: 'image',
};
this.changeIcon = this.changeIcon.bind(this);
}
changeIcon() {
this.setState({icon: 'delete'});
console.log(this.state.icon);
}
render() {
return (
<List>
{(this.state.files || []).map((file, i) => {
return (
<List.Item
//icon="image"
icon={`${this.state.icon}`}
content={file.name}
onClick={this.handleRemove}
onChange={this.changeIcon}
/>
);
})}
</List>
);
}
完整代码在这里:
https://github.com/jpskgc/article/blob/master/client/src/components/Detail.tsx
答案 0 :(得分:0)