流浪のwolf

卷帝

导航

前端文件打开并且读取内容展示

1. 函数封装

const onloadend1 = (e: any, a: any) => {
  const { graph } = FlowGraph
const reader = new FileReader();
 const fileList = fileRef1.value.files  // 这个就是选中的文件流
 if (!fileList.length) return
 reader.readAsText(fileList[0], "UTF-8");
 reader.onload = function (event: any) {
  console.log(event.target.result)  // 这个就是文件内容
  graph.fromJSON(JSON.parse(event.target.result))
 }
}

 

posted on 2023-07-13 14:37  流浪のwolf  阅读(12)  评论(0编辑  收藏  举报