diff --git "a/\346\235\216\345\200\241\347\246\217/20240512--" "b/\346\235\216\345\200\241\347\246\217/20240512--" new file mode 100644 index 0000000000000000000000000000000000000000..21d170c50e5d36ea015320ea2bab50903ee5d88e --- /dev/null +++ "b/\346\235\216\345\200\241\347\246\217/20240512--" @@ -0,0 +1 @@ +shaoden \ No newline at end of file diff --git "a/\346\235\216\345\200\241\347\246\217/20240512--.md" "b/\346\235\216\345\200\241\347\246\217/20240512--.md" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\346\235\216\345\200\241\347\246\217/20240513--.md" "b/\346\235\216\345\200\241\347\246\217/20240513--.md" new file mode 100644 index 0000000000000000000000000000000000000000..ecb9fafb1e026c3eb913e971ed27974a8dbb67df --- /dev/null +++ "b/\346\235\216\345\200\241\347\246\217/20240513--.md" @@ -0,0 +1,204 @@ +diff --git "a/\346\235\250\345\217\257\347\233\210/20240513--pinia.md" "b/\346\235\250\345\217\257\347\233\210/20240513--pinia.md" +new file mode 100644 +index 0000000000000000000000000000000000000000..01498fe1c3c14b6a599edb94cd58b1128e85c2bb +--- /dev/null ++++ "b/\346\235\250\345\217\257\347\233\210/20240513--pinia.md" +@@ -0,0 +1,53 @@ ++### pinia ++``` ++Pinia 是 Vue 的专属状态管理库,它允许你跨组件或页面共享状态。如果你熟悉组合式 API 的话,你可能会认为可以通过一行简单的 export const state = reactive({}) 来共享一个全局状态。对于单页应用来说确实可以,但如果应用在服务器端渲染,这可能会使你的应用暴露出一些安全漏洞。 而如果使用 Pinia,即使在小型单页应用中,你也可以获得如下功能: ++ ++Devtools 支持 ++追踪 actions、mutations 的时间线 ++在组件中展示它们所用到的 Store ++让调试更容易的 Time travel ++热更新 ++不必重载页面即可修改 Store ++开发时可保持当前的 State ++插件:可通过插件扩展 Pinia 功能 ++为 JS 开发者提供适当的 TypeScript 支持以及自动补全功能。 ++支持服务端渲染 ++``` ++ ++``` ++yarn add pinia ++``` ++ ++```js ++// stores/counter.js ++import { defineStore } from 'pinia' ++ ++export const useCounterStore = defineStore('counter', { ++ state: () => { ++ return { count: 0 } ++ }, ++ // 也可以这样定义 ++ // state: () => ({ count: 0 }) ++ actions: { ++ increment() { ++ this.count++ ++ }, ++ }, ++}) ++``` ++ ++```vue ++ ++ ++``` +\ No newline at end of file +diff --git "a/\346\235\250\345\217\257\347\233\210/20240516--\350\267\257\347\224\261\345\244\215\344\271\240.md" "b/\346\235\250\345\217\257\347\233\210/20240516--\350\267\257\347\224\261\345\244\215\344\271\240.md" +new file mode 100644 +index 0000000000000000000000000000000000000000..5a63af70e15fbd2244baf4721c3363144226daef +--- /dev/null ++++ "b/\346\235\250\345\217\257\347\233\210/20240516--\350\267\257\347\224\261\345\244\215\344\271\240.md" +@@ -0,0 +1,134 @@ ++```js ++import { onMounted, reactive,ref } from 'vue' ++ import {useRouter} from 'vue-router' ++ import axios from 'axios' ++ ++ let blogs=reactive([ ++ ++ ]) ++ ++ let query=ref('') ++ ++ let router=useRouter() ++ onMounted(async()=>{ ++ let res=await axios.get(`http://localhost:3000/blogs`) ++ console.log(res); ++ res.data.data.forEach(item=>{ ++ blogs.push(item) ++ }) ++ }) ++ ++ function btnAdd(){ ++ router.push('/editadd') ++ } ++ ++ function btnEdit(id){ ++ router.push( ++ { ++ path:`/editadd`,query:{id:id} ++ } ++ ) ++ } ++ async function btnQuery(){ ++ let res=await axios.get(`http://localhost:3000/blogs?keyword=${query.value}`) ++ blogs.splice(0) ++ console.log(query); ++ res.data.data.forEach(item=>{ ++ blogs.push(item) ++ }) ++ } ++ async function btnDel(id){ ++ if(confirm(`你确定要删除id为${id}的数据吗`)){ ++ let index=blogs.findIndex(item=>item.id===id) ++ blogs.splice(index,1) ++ let res=await axios.delete(`http://localhost:3000/blogs/${id}`) ++ console.log(res); ++ } ++ // let res=await axios.delete(`http://localhost:3000/blogs/${id}`) ++ // let idx ++ // if(confirm(`确定删除id为${id}的数据吗`)){ ++ // if(res.data.code===1000){ ++ // blogs.filter((item,index)=>{ ++ // let result=item.id===id ++ // if(result){ ++ // idx=index ++ // return ++ // } ++ // }) ++ // blogs.splice(idx,1) ++ // } ++ // } ++ } ++ ++ ++ ++``` ++ ++```js ++import {useRouter,useRoute} from 'vue-router' ++import {reactive,onMounted} from 'vue' ++import axios from 'axios' ++ ++let router=useRouter() ++let route=useRoute() ++let add=reactive({ ++ title:"", ++ author:"", ++ flag:"" ++}) ++ ++onMounted(async()=>{ ++ let id=route.query.id ++ console.log(id); ++ if(id>0){ ++ let edit=await axios.get(`http://localhost:3000/blogs/${id}`) ++ add.title=edit.data.data.title, ++ add.author=edit.data.data.author, ++ add.flag=edit.data.data.flag, ++ add.id=edit.data.data.id ++ } ++}) ++ ++async function btnSave(){ ++ let obj={ ++ title:add.title, ++ author:add.author, ++ flag:add.flag, ++ } ++ if(add.id>0){ ++ await axios.put(`http://localhost:3000/blogs/${add.id}`,obj) ++ }else{ ++ await axios.post(`http://localhost:3000/blogs`,obj) ++ } ++ router.push('/') ++} ++ ++function btnCancel(){ ++ router.push('/') ++} ++``` +\ No newline at end of file +diff --git "a/\346\235\250\345\217\257\347\233\210/img/blog.gif" "b/\346\235\250\345\217\257\347\233\210/img/blog.gif" +index 782d6677723d1268cd1875d33c9149d00804d0ce..c7908d4cb7803a22df22e08469954a72dfd511c3 100644 +Binary files "a/\346\235\250\345\217\257\347\233\210/img/blog.gif" and "b/\346\235\250\345\217\257\347\233\210/img/blog.gif" differ \ No newline at end of file diff --git "a/\346\235\216\345\200\241\347\246\217/20240516--.md" "b/\346\235\216\345\200\241\347\246\217/20240516--.md" new file mode 100644 index 0000000000000000000000000000000000000000..42ed8b6878c07c603216f5404e03a8292640e753 --- /dev/null +++ "b/\346\235\216\345\200\241\347\246\217/20240516--.md" @@ -0,0 +1 @@ +稍等 \ No newline at end of file diff --git "a/\346\235\216\345\200\241\347\246\217/img/20201106213232898.png" "b/\346\235\216\345\200\241\347\246\217/img/20201106213232898.png" deleted file mode 100644 index 466d69a91e51068602fb4b00231f2ffe3cffe6fe..0000000000000000000000000000000000000000 Binary files "a/\346\235\216\345\200\241\347\246\217/img/20201106213232898.png" and /dev/null differ diff --git "a/\346\235\216\345\200\241\347\246\217/img/33.png" "b/\346\235\216\345\200\241\347\246\217/img/33.png" deleted file mode 100644 index 5a8830c10719f11ca0ec1740765d8212ce7f2cd7..0000000000000000000000000000000000000000 Binary files "a/\346\235\216\345\200\241\347\246\217/img/33.png" and /dev/null differ diff --git "a/\346\235\216\345\200\241\347\246\217/img/88.png" "b/\346\235\216\345\200\241\347\246\217/img/88.png" deleted file mode 100644 index 950938212dbda2c1c700609fd4192662ad0dc8e6..0000000000000000000000000000000000000000 Binary files "a/\346\235\216\345\200\241\347\246\217/img/88.png" and /dev/null differ diff --git "a/\346\235\216\345\200\241\347\246\217/img/99.png" "b/\346\235\216\345\200\241\347\246\217/img/99.png" deleted file mode 100644 index 769cf11c6251819f1d63511ab25def91c2cb0b9b..0000000000000000000000000000000000000000 Binary files "a/\346\235\216\345\200\241\347\246\217/img/99.png" and /dev/null differ diff --git "a/\346\235\216\345\200\241\347\246\217/img/demo.jpg" "b/\346\235\216\345\200\241\347\246\217/img/demo.jpg" deleted file mode 100644 index a1f70c8aba684a20b9155bbb780ce9f70b7874d3..0000000000000000000000000000000000000000 Binary files "a/\346\235\216\345\200\241\347\246\217/img/demo.jpg" and /dev/null differ