我正在使用Vue.js在网页表中显示本地存储文件中的json数据。我还想通过使用来自表单的数据来更新json文件中的数据。但是我得到了上面提到的错误
import json from "../assets/data.json";
export default{
json,
data(){
return{
title: '',
date: new Date().toISOString().substr(0, 10),
modal: false,
menu2: false,
dialog: false,
notifications: false,
sound: true,
widgets: false,
task: '',
tasks: {},
}
},
methods: {
submit: function(){
this.tasks = {id: json.length+1, task:this.task,date: this.date, complete: false}
json.push(this.tasks)
var file = require('fs')
file.writeFile('../assets/data.json', json)
}
reset1(){
this.task = '';
this.date = new Date().toISOString().substr(0, 10);
}
},
name: "Form"
};
</script>