从 react 导出到 rtf
Exporting from react to rtf
我正在使用 React 构建一个会议管理应用程序。
我想添加一个结束会议按钮,用于导出存储在某个状态下的会议摘要。
我可以将状态的内容导出到 RTF 文件吗?
您可以使用 Blob
对象创建 RTF。
参见下面的示例。
import React from "react";
class MyApp extends React.Component {
constructor(props) {
super(props);
this.state = {
summary: "Hello this is summary"
};
}
onEndMeeting = () => {
const element = document.createElement("a");
const file = new Blob([this.state.summary], { type: "text/plain" });
element.href = URL.createObjectURL(file);
element.download = "myFile.txt";
document.body.appendChild(element);
element.click();
};
render() {
return (
<div>
<button onClick={this.onEndMeeting}>End Meeting</button>
</div>
);
}
}
export default MyApp;
Stackblitz 演示:Click here
我正在使用 React 构建一个会议管理应用程序。 我想添加一个结束会议按钮,用于导出存储在某个状态下的会议摘要。 我可以将状态的内容导出到 RTF 文件吗?
您可以使用 Blob
对象创建 RTF。
参见下面的示例。
import React from "react";
class MyApp extends React.Component {
constructor(props) {
super(props);
this.state = {
summary: "Hello this is summary"
};
}
onEndMeeting = () => {
const element = document.createElement("a");
const file = new Blob([this.state.summary], { type: "text/plain" });
element.href = URL.createObjectURL(file);
element.download = "myFile.txt";
document.body.appendChild(element);
element.click();
};
render() {
return (
<div>
<button onClick={this.onEndMeeting}>End Meeting</button>
</div>
);
}
}
export default MyApp;
Stackblitz 演示:Click here