类型错误无法设置未定义的属性'_minWidth' - pdfmake,Angular 2
Posted
技术标签:
【中文标题】类型错误无法设置未定义的属性\'_minWidth\' - pdfmake,Angular 2【英文标题】:Type Error Cannot set property '_minWidth' of undefined - pdfmake, Angular 2类型错误无法设置未定义的属性'_minWidth' - pdfmake,Angular 2 【发布时间】:2018-06-18 13:53:20 【问题描述】:我正在尝试为我的表格添加宽度,但由于某种原因我得到以下错误:
Component.html:187 ERROR TypeError: Cannot set property '_minWidth' of undefined at DocMeasure.measureTable (pdfmake.js:4487)
at pdfmake.js:4012
at StyleContextStack.auto (pdfmake.js:6069)
at DocMeasure.measureNode (pdfmake.js:3999)
at DocMeasure.measureVerticalContainer (pdfmake.js:4216)
at pdfmake.js:4006
at StyleContextStack.auto (pdfmake.js:6069)
at DocMeasure.measureNode (pdfmake.js:3999)
at DocMeasure.measureDocument (pdfmake.js:3992)
at LayoutBuilder.tryLayoutDocument (pdfmake.js:3120)
at LayoutBuilder.layoutDocument (pdfmake.js:3107)
at PdfPrinter.createPdfKitDocument (pdfmake.js:2383)
at Document._createDoc (pdfmake.js:105)
at Document.getBuffer (pdfmake.js:243)
at Document.getBlob (pdfmake.js:233)
问题行
widths: ['auto', 'auto', 'auto', 'auto'],
我的文档定义
var docDefinition =
content: [
text: 'Section A: Facilities and Ambience', style: 'sectionStyling',
style: 'tableExample',
table:
widths: ['auto', 'auto', 'auto', 'auto'],
body: [
['col1', 'col2', 'col3', 'col4', 'col5'],
['some text', '1', '1', '100%', '-'],
['some text', '1', '1', '100%', '-'],
['some text', '1', '1', '100%', '-'],
['some text', '1', '1', '100%', '-'],
['some text', '1', '1', '100%', '-'],
['some text', '1', '1', '100%', '-'],
['some text', '1', '1', '100%', '-'],
['some text', '1', '1', '100%', '-']
]
],
background: function ()
return [
image: 'watermark',
width: 200,
alignment : 'center',
margin: [0, 325, 0, 0]
];
,
images:
watermark: 'data:image/base64....'
,
styles:
sectionStyling:
fontSize: 18,
color: 'blue',
bold: true,
alignment: 'right',
margin: [0, 190, 0, 80]
,
subheader:
fontSize: 14
,
superMargin:
margin: [20, 0, 40, 0],
fontSize: 15
,
defaultStyle:
alignment: 'justify'
;
我试过了(以下都没有):
widths: ['auto', 'auto', 'auto', 'auto'],
widths: ['auto', 'auto', 'auto'],
widths: [100, '*', 200, '*'],
It works if I just remove the widths line.
【问题讨论】:
【参考方案1】:您有五列,但只设置了四个宽度。尝试为所有这些设置宽度:
widths: ['auto', 'auto', 'auto', 'auto', 'auto'];
【讨论】:
哦,好吧,我想到了css的宽度。让我测试一下 如果这不起作用,请尝试在宽度数组中添加五个 width: 'auto'
对象以上是关于类型错误无法设置未定义的属性'_minWidth' - pdfmake,Angular 2的主要内容,如果未能解决你的问题,请参考以下文章