【发布时间】:2017-03-30 11:01:31
【问题描述】:
在示例TodoMVC 中,我知道我可以挂钩fetch 和save 函数以使用jQuery Ajax Get/Post 与后端API 交互以进行远程存储。
例如
var todoStorage = {
fetch: function () {
var todos = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]')
todos.forEach(function (todo, index) {
todo.id = index
})
todoStorage.uid = todos.length
return todos
},
save: function (todos) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(todos))
}
}
但是由于我的后端已经是 RESTful API,有没有更优雅的方式来更整洁地映射我的 Restful API?
【问题讨论】:
标签: jquery rest vue.js vue-resource