reactjs - 当我尝试做反应弹出示例时,它不起作用
问题描述
我正在尝试做这个反应弹出的例子,但它似乎不起作用。
https://github.com/JakeGinnivan/react-popout#readme
示例在底部。
import React from "react"
import Popout from "react-popout"
class PopupLogin extends React.Component {
constructor(props) {
super(props);
this.popout = this.popout.bind(this);
this.popoutClosed = this.popoutClosed.bind(this);
this.state = { isPoppedOut: false };
}
popout() {
this.setState({isPoppedOut: true});
}
popoutClosed() {
this.setState({isPoppedOut: false});
}
render() {
if (this.state.isPoppedOut) {
return (
<Popout title='Window title' onClosing={this.popoutClosed}>
<div>Popped out content!</div>
</Popout>
);
} else {
var popout = <span onClick={this.popout} className="buttonGlyphicon glyphicon glyphicon-export"></span>
return (
<div>
<strong>Section {popout}</strong>
<div>Inline content</div>
</div>
);
}
}
}
export default PopupLogin
这应该看起来像http://jake.ginnivan.net/react-popout/这个。但在我的输出中看起来像这样。
解决方案
看起来文档中的代码缺少文本。(pop window out)
在弹出窗口中添加。
import React from "react";
import Popout from "react-popout";
class PopupLogin extends React.Component {
constructor(props) {
super(props);
this.popout = this.popout.bind(this);
this.popoutClosed = this.popoutClosed.bind(this);
this.state = { isPoppedOut: false };
}
popout() {
this.setState({ isPoppedOut: true });
}
popoutClosed() {
this.setState({ isPoppedOut: false });
}
render() {
if (this.state.isPoppedOut) {
return (
<Popout title="Window title" onClosing={this.popoutClosed}>
<div>Popped out content!</div>
</Popout>
);
} else {
var popout = (
<span
onClick={this.popout}
className="buttonGlyphicon glyphicon glyphicon-export"
>
<a
style={{
textDecoration: "underline",
color: "blue",
cursor: "pointer"
}}
onClick={this.popout}
>
(pop window out)
</a>
</span>
);
return (
<div>
<strong>Section {popout}</strong>
<div>Inline content</div>
</div>
);
}
}
}
export default PopupLogin;
推荐阅读
- java - 每次我打开一个项目时,Android Studio 都会尝试下载一个 gradle 版本
- c# - 添加多个 GET 动词会产生 AmbiguousMatchException 错误
- python - Can you print tables on a popup window or on a screen in kivy (python)
- reporting-services - 在 Microsoft Report Builder / SSRS 18.4 的报告中消除额外/空白页(它们有标题)
- appium - 找不到 uiautomatorviewer-26.0.0-dev.jar
- internet-explorer - 清除 IE11 上的请求缓存 - 将 POST 保存为 GET
- java - setVisibility(View.GONE) 缩小显示尺寸
- c++ - 头文件中声明的变量不能在主文件中使用?
- c - 为什么内核不清除进程中第二个malloc分配的内存?
- python - 为什么此代码在重复函数调用后会抛出错误?