只是尝试从Elastic UI库中添加一个按钮,但在添加按钮时未定义仅获取一个窗口。在我添加按钮组件或在下面的第 3 行添加导入之前,API 调用和其他一切工作正常。
在进行服务器端 api 调用时,有没有办法使用 Elastic UI 库?
这是主要代码:
import React from "react";
import "isomorphic-unfetch";
import { EuiButton } from "@elastic/eui";
export default class HomePage extends React.Component {
static async getInitialProps() {
let res = await fetch("https://api.randomuser.me/");
let randUser = await res.json();
console.log(randUser);
return { users: randUser };
}
render() {
return (
<div>
<h2>User info:</h2>
<ul>
{this.props.users.results.map((user, i) => {
return <li key={"user-" + i}>{user.gender}</li>;
})}
</ul>
<EuiButton href="http://www.elastic.co">Link to elastic.co</EuiButton>
</div>
);
}
}