作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在 Angular JS 中创建一个待办事项列表,在计算机系统中以文件形式存储待办事项列表。我已经尝试过使用 http 服务:get 和 post。但我这样做时遇到错误..待办事项列表存储在网络存储中,但不存储在计算机中
最佳答案
这将允许您右键单击并另存为 JSON 文件。
然后您可以在计算机上使用所述文件或将其上传到同一网站或另一个网站:
//Reference a tag
var link = document.getElementById("downloadLink");
//Dummy data todos
var todos = [{
name: 1,
text: "hello world"
},{
name: 2,
text: "hello world"
}];
//Create download link
link.setAttribute("href", 'data:text/json,' + JSON.stringify(todos))
<a id="downloadLink" href="#nuthinYet" target="_blank" download="test.json">download</a>
关于javascript - 创建待办事项列表 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41299233/
我是一名优秀的程序员,十分优秀!