node将数组写到一个js文件中

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/adley_app/article/details/83577595
const fs = require('fs');

let arr = [
    1,
    2,
    3,
    'abc'
]

fs.writeFile("url.js",'let articleUrlList = ' + JSON.stringify(arr), err => {
    if(!err) console.log("success~");
});
  • urls.js
let articleUrlList = [1, 2, 3, "abc"]

猜你喜欢

转载自blog.csdn.net/adley_app/article/details/83577595