jQuery文件下载 - 缺少文件扩展名

时间:2018-01-17 10:11:45

标签: javascript jquery

我正在使用table2CSV将HTML表格转换为使用此jQuery的CSV文件

$ npm install -g purify-css

purifycss <css> <content> [option]

Options:
  -m, --min        Minify CSS                         [boolean] [default: false]
  -o, --out        Filepath to write purified css to                    [string]
  -i, --info       Logs info on how much css was removed
                                                      [boolean] [default: false]
  -r, --rejected   Logs the CSS rules that were removed
                                                      [boolean] [default: false]
  -w, --whitelist  List of classes that should not be removed
                                                           [array] [default: []]
  -h, --help       Show help                                           [boolean]
  -v, --version    Show version number                                 [boolean]

一切正常但生成的文件名为'download'

如果我将其重命名为download.csv,那么它会正确打开,有没有办法设置文件名?

1 个答案:

答案 0 :(得分:0)

尝试将下载属性添加到按钮:

 $button[0].setAttribute("download", 'FileName.csv');