首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >希望在单击IconFont后打开对话框窗口。

希望在单击IconFont后打开对话框窗口。
EN

Stack Overflow用户
提问于 2017-10-10 13:24:44
回答 1查看 43关注 0票数 0

我的工作与反应,是非常新的。我有一个有一堆FontIcons的页面。我希望用户点击一个图标,并有一个对话框弹出。我在对话框中找到了信息,http://www.material-ui.com/#/components/dialog。我还没有找到任何关于如何使onclick操作呈现对话框组件的内容。

我知道我需要在这里加些东西..。

代码语言:javascript
复制
<a style={{position: 'absolute', bottom: 0, right: 0, cursor: 'pointer'}} onTouchTap={() => manageBookmark(parsedParams, this.props.documentRdxDoc.acm, this.props.documentRdxDoc.docTitle)}>
<Tooltip label='Manage Bookmark' position='right'>
<FontIcon className='material-icons' style={{color: 
 appConfig.globalFontColor}} tooltip="Notifications">star</FontIcon>
</Tooltip>
</a>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-10 13:40:32

您需要创建对话框组件本身,然后在单击FontIcon时显示它(使用onClick属性)。

可以使用组件状态对象跟踪对话框状态,并通过处理程序方法进行修改。

下面是一个基于文档站点的示例:

代码语言:javascript
复制
export default class DialogButtonSample extends React.Component {
  state = {
    open: false,
  };

  handleOpen = () => {
    this.setState({open: true});
  };

  handleClose = () => {
    this.setState({open: false});
  };

  render() {
    const actions = [
      <FlatButton
        label="Cancel"
        primary={true}
        onClick={this.handleClose}
      />,
      <FlatButton
        label="Submit"
        primary={true}
        disabled={true}
        onClick={this.handleClose}
      />,
    ];

    return (
        <div>
            <a style={{position: 'absolute', bottom: 0, right: 0, cursor: 'pointer'}} onTouchTap={() => manageBookmark(parsedParams, this.props.documentRdxDoc.acm, this.props.documentRdxDoc.docTitle)}>
                <Tooltip label='Manage Bookmark' position='right'>
                    <FontIcon className='material-icons' style={{color: appConfig.globalFontColor}} tooltip="Notifications" onClick={this.handleOpen}>star</FontIcon>
                </Tooltip>
                <Dialog
                  title="Dialog With Actions"
                  actions={actions}
                  modal={false}
                  open={this.state.open}
                  onRequestClose={this.handleClose}
                >
            </a>
        </div>
    );
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46667960

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档