mirror of
https://gitee.com/bitdance-team/chrome-extension
synced 2025-01-31 15:30:25 +08:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
|
||
|
let app = new Vue({
|
||
|
data() {
|
||
|
return {
|
||
|
todos: [],
|
||
|
todoForm: "",
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
loadTodos () {
|
||
|
axios.get("https://qcmma8.app.cloudendpoint.cn/api/memos?pageSize=100").then(res => {
|
||
|
this.todos = res.data.content
|
||
|
})
|
||
|
},
|
||
|
createTodo () {
|
||
|
if (!this.toDoForm.trim()) {
|
||
|
alert('内容不能为空')
|
||
|
return
|
||
|
}
|
||
|
axios.post("https://qcmma8.app.cloudendpoint.cn/api/memos", { content: this.toDoForm }).then(() => {
|
||
|
alert('添加成功!')
|
||
|
this.loadTodos()
|
||
|
this.toDoForm = ""
|
||
|
})
|
||
|
},
|
||
|
removeTodo(id) {
|
||
|
axios.delete(`https://qcmma8.app.cloudendpoint.cn/api/memos/${id}`, {
|
||
|
content: this.toDoForm
|
||
|
}).then(() => {
|
||
|
alert('删除成功!')
|
||
|
this.loadTodos()
|
||
|
})
|
||
|
},
|
||
|
},
|
||
|
mounted () {
|
||
|
this.loadTodos()
|
||
|
}
|
||
|
})
|
||
|
|
||
|
function sessionCb() {
|
||
|
app.$mount('#app')
|
||
|
}
|