如何通过点击按钮添加json数据到js文件
下面是data.js文件
var user_data = {
files: [
{
name: 'Root',
id: 0,
type: 'root',
type:'folder',
time: '2017-01-01',
children: [
{
name: 'Front Frame',
id: 1,
pId: 0,
type:'folder',
time: '2017-10-02',
children: [
{
name: 'React',
id: 4,
pId: 1,
type:'folder',
time: '2017-01-03',
children: []
},
{
name: 'Vue',
id: 5,
pId: 1,
type:'folder',
time: '2017-01-04',
children: [
{
name: 'vue-cli',
id: 6,
pId: 5,
type:'folder',
time: '2017-01-04',
children: []
}
]
}
]
},
{
name: 'HTML5',
id: 2,
pId: 0,
type:'folder',
time: '2017-01-01',
children: []
},
{
name: 'CSS3',
id: 3,
pId: 0,
type:'folder',
time: '2017-05-01',
children:[]
},
]
}
]
};
如何通过按钮把下面这组数据添加进data.js
var newFolder = {
id: currentDataId,
name: '新建文件夹',
type: 'folder',
time: '2018-01-01',
children: []
}