search

Home  >  Q&A  >  body text

node.js - nodeJS 写入文件的内容怎么不是按次序的?

PHP中文网PHP中文网2776 days ago601

reply all(4)I'll reply

  • 高洛峰

    高洛峰2017-04-17 14:49:18

    Because it’s asynchronous

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 14:49:18

    fs.appendFile Asynchronous, please use fs.appendFileSync

    for synchronization

    https://nodejs.org/api/fs.htm...

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 14:49:18

    It is recommended that you concatenate the strings before writing them to the file. . .

    reply
    0
  • 阿神

    阿神2017-04-17 14:49:18

    Most nodejs file operation APIs are divided into asynchronous/synchronous (fs.xxx/fs.xxxSync). Just change it to synchronized function content.

    reply
    0
  • Cancelreply