search

Home  >  Q&A  >  body text

node.js - 页面上有一个按钮,点击之后会下载一个jar包,如何实现?

我的项目是react+webpack+redux的结构,jar包是已经有的.我在网上看到用a标签的方法.i.e.点击下载 但是这个方法点击之后都是去访问localhost:9000/assets/sender.txt.

ringa_leeringa_lee2783 days ago726

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 15:25:57

    Add
    { 

    to loaders: [] in the webpack configuration file

    test: /.jar$/,
    include: srcPath,
    loader: 'file-loader?name=jar/[name].[ext]'
    }

    Introduce the jar package into src/component/caseList/CaseOperations.jsx where the a tag is located. My jar package is placed under src, so import { caseSender } from '../../case-sender.jar' ,<a href={caseSender} download>Export</a>

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 15:25:57

    Did you write the address of the jar package in href?

    reply
    0
  • Cancelreply