小编Zic*_*ang的帖子

HTML,react.js如何制作一个下载按钮来下载HTML页面内容?

我是react.js 和Javascript 的新手。我的工作是在图片上方添​​加一个下载按钮,点击后就会下载SVG格式的图片。我有一种方法有效,我将下载函数写入图像生成文件中,并调用该函数。但是只要我需要添加更多按钮,我发现图像svg文件在html页面里面。为什么我不能直接将 svg 内容保存到文件中。例如:按钮下载内容在我的react.js代码中,RankedBarchart渲染就是我想要的。有什么方法可以直接获取内容或下载内容。

 <h2>
   BMC values: sorted by {chartName}{' '}
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <button onClick={plot_download_form} class="btn btn-primary">
      Export plot
   </button>
 </h2>
 <RankedBarchart
   // the visualization function not affect the plot
   // the selectedAxis is the main function to show tables,
   // check the RankedBarchart file, selectedAxis part
   data={plotData}
   visualization={this.props.visualization}
   selectedAxis={this.props.selectedAxis}
  />               
Run Code Online (Sandbox Code Playgroud)

HTML 页面内容

html javascript reactjs

0
推荐指数
1
解决办法
3595
查看次数

标签 统计

html ×1

javascript ×1

reactjs ×1