使用
fs
模塊,往本地磁盤中寫文件。
在Electron開發時,使用fs
模塊往本地文件中寫入內容。
// 引入fs模塊
const fs = require('fs');
//this.codemirror.getValue() 為我們要寫入的內容,使用時請自行替換。
fs.writeFile(this.path, this.codemirror.getValue(), (err) => {
if (err) {
console.log(err);
} else {
this.$message({
message: '保存成功',
type: 'success'
});
}
})