Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 新行未在docx.js中注册_Javascript_Reactjs_Docx - Fatal编程技术网

Javascript 新行未在docx.js中注册

Javascript 新行未在docx.js中注册,javascript,reactjs,docx,Javascript,Reactjs,Docx,我正在使用docxjs库。我正在尝试将换行符添加到我生成的文档中,但我不确定如何执行此操作\n字符被忽略。如何在我的文档中添加换行符 我想添加换行符的段落: new Paragraph( { text: '\n', children: [ ...Object.entries( dataItem ).map( ([fieldName, fieldValue]) => new Paragraph( { text: fi

我正在使用docxjs库。我正在尝试将换行符添加到我生成的文档中,但我不确定如何执行此操作<代码>\n字符被忽略。如何在我的文档中添加换行符

我想添加换行符的段落:

new Paragraph( {
        text: '\n',
        children: [
          ...Object.entries( dataItem ).map( ([fieldName, fieldValue]) => new Paragraph( {
            text: fieldName,
            children: Object.entries( fieldValue ).map( ([dataSource, dataValue]) => new Paragraph( {
              text: dataSource,
              children: Object.values( dataValue ).map( value => new Paragraph(value) )
            }) )
          }) ),
          new Paragraph( {text: '_', children: [new PageBreak()]} )
        ]
      } )

我认为那一段在正文中等于换行符。不是吗

doc.addSection({
    properties: {},
    children: [
        new Paragraph({
            children: [
                new TextRun("First line"),
            ],
        }),
        new Paragraph({
          children: [],  // Just newline without text
        }),
        new Paragraph({
            children: [
                new TextRun("Second line"),
            ],
        }),
    ],
});

它确实创建了一个新行,但它也需要文本,所以如果我只想要一个没有文本的新行,我就不能使用它。新段落({children:[],}),我编辑了上面的示例。谢谢,但是这不是一个黑客吗?难道不应该有一种简单的方法来插入换行符吗?我想这不是因为Word文档的结构也使用这种方法。