NPM Datatable Excel按钮未显示 [英] NPM Datatable Excel button not showing
问题描述
我的 Excel 按钮现在显示.我正在使用NPM导入所有脚本,所有其他按钮都可以正常使用( PDF,复制,打印).只有 Excel 无效.
My Excel Button in datatable is now showing up. I'm using NPM to import all scripts, all others buttons works well (PDF, Copy, Print). Only Excel do not work.
检查我的进口商品:
import 'datatables.net-bs'
import 'datatables.net-buttons-bs'
import 'datatables.net-responsive-bs'
import 'datatables.net-buttons/js/buttons.colVis.js'
import 'datatables.net-buttons/js/buttons.flash.js'
import 'jszip'
import pdfMake from 'pdfmake/build/pdfmake'
import pdfFonts from 'pdfmake/build/vfs_fonts'
import 'datatables.net-buttons/js/buttons.html5.js'
import 'datatables.net-buttons/js/buttons.print.js'
pdfMake.vfs = pdfFonts.pdfMake.vfs
我的配置:
let datatableConfig = {
responsive: true,
"dom": '<"html5buttons"B>lTfgtip',
"buttons": [
{ extend: 'copy' },
{ extend: 'excel'},
{ extend: 'excelHtml5' },
{ extend: 'pdf' },
{ extend: 'print' }
]
};
$('#dataTable').DataTable(datatableConfig)
如果我将
https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.4/jszip.min.js
直接放在HTML中,则可以正常工作.使用import
如何不起作用? (是的,已经安装了jszip)
If i put
https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.4/jszip.min.js
direct in my HTML, it works. How it do not work usingimport
? (Yes, jszip is already installed)
谢谢!
推荐答案
我在require
语法上遇到了同样的问题,我不得不这样做:
I got the same issue with the require
syntax and I had to do :
window.JSZip = require( "jszip" );
我不知道import
的语法,但也许有点像
I don't know the syntax with import
but maybe it's something like
import window.JSZip from 'jszip';
或
JSZip from 'jszip';
或
import JSZip from 'jszip';
window.JSZip = JSZip;
这篇关于NPM Datatable Excel按钮未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!