+
+ count: {{ counter.count }}
+
+
+
+
+
+
+```
+- 4.变更
+- 用 store.count++ 直接改变 store,还可以调用 $patch 方法
+
+- 5.替换
+- 不能完全替换掉 store 的 state,因为那样会破坏其响应性,还是使用patch
+
+- 四、Getter
+- Getter 完全等同于 store 的 state 的计算属性
+```js
+export const useCountStore = defineStore('count',{
+ state:()=>{
+ return {count:1}
+ },
+ actions:{
+ onClick(){
+ this.count++
+ }
+ },
+ getters: {
+ doubleCount: (state) => state.count * 2,
+ },
+})
+```
+
+- 大多数时候,getter 仅依赖 state,不过,有时它们也可能会使用其他 getter,通过 this,你可以访问到其他任何 getter
+- getter 只是幕后的计算属性,所以不可以向它们传递任何参数。不过,你可以从 getter 返回一个函数,该函数可以接受任意参数
+```js
+export const useUsersStore = defineStore('users', {
+ getters: {
+ getUserById: (state) => {
+ // 可以返回函数,这个返回的函数可以接受容易参数
+ return (userId) => state.users.find((user) => user.id === userId)
+ },
+ },
+})
+```
+ // 调用
+五、Action
+Action 相当于组件中的方法,也可通过 this 访问整个 store 实例,而且是可以异步的
+## Api
+Application Programming Interface(应用程序接口)是它的全称。简单的理解就是,API是一个接口
+
+## rest
+HTTP总共包含八种方法:
+
+GET
+POST
+PUT
+DELETE
+OPTIONS
+HEAD
+TRACE
+CONNECT
+● 2xx = Success(成功)
+
+● 3xx = Redirect(重定向)
+
+● 4xx = User error(客户端错误)
+
+● 5xx = Server error(服务器端错误)
+
+我们常见的是200(请求成功)、404(未找到)、401(未授权)、500(服务器错误)...
\ No newline at end of file
diff --git "a/\345\224\220\345\244\251\345\250\245/20240516-\345\244\215\344\271\240.md" "b/\345\224\220\345\244\251\345\250\245/20240516-\345\244\215\344\271\240.md"
new file mode 100644
index 0000000..8ab6db9
--- /dev/null
+++ "b/\345\224\220\345\244\251\345\250\245/20240516-\345\244\215\344\271\240.md"
@@ -0,0 +1,146 @@
+## 复习代码
+```js
+
+
+