teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コードの追加

2021/09/28 07:31

投稿

wepowepon
wepowepon

スコア1

title CHANGED
File without changes
body CHANGED
@@ -63,7 +63,7 @@
63
63
  //async 非同期関数
64
64
  const logout = async () => {
65
65
  alert("通過") //検証用(現在ここが表示されません)
66
- )
66
+
67
67
  axios.post('logout', {})
68
68
  store.dispatch('setaAuth', false)
69
69
  router.push('/login')
@@ -75,11 +75,34 @@
75
75
  }
76
76
  </script>
77
77
  ```
78
+ ```index.ts
79
+ //index.ts
80
+ //vuexででログイン状態を管理しています
78
81
 
82
+ import { Commit, createStore } from 'vuex'
83
+
84
+ export default createStore({
85
+ state: {
86
+ auth: false
87
+ },
88
+ mutations: {
89
+ setAuth: (state: { auth: boolean }, auth: boolean) => state.auth = auth
90
+ },
91
+ actions: {
92
+ setAuth: ({commit}: { commit: Commit }, auth: boolean) => commit('setAuth', auth)
93
+ },
94
+ modules: {
95
+ }
96
+ })
97
+ ```
98
+
79
99
  ### 試したこと
80
100
 
81
101
  ・@clickをv-onの表記に変更してみる
82
102
 
83
103
  ### 補足情報(FW/ツールのバージョンなど)
84
104
 
85
- @vue/cli 4.5.13
105
+ @vue/cli 4.5.13
106
+
107
+ 以下のサイトを参考にしました▼
108
+ [Go言語とVue.jsで作るユーザー認証アプリ~フロントエンド開発編](https://selfnote.work/20210209/programming/create-authentication-app-with-golang-and-vue3-8/)

1

試したこと・補足情報の追記

2021/09/28 07:31

投稿

wepowepon
wepowepon

スコア1

title CHANGED
File without changes
body CHANGED
@@ -78,8 +78,8 @@
78
78
 
79
79
  ### 試したこと
80
80
 
81
- ・@clickをv-onの表記に変更してみる
81
+ ・@clickをv-onの表記に変更してみる
82
82
 
83
83
  ### 補足情報(FW/ツールのバージョンなど)
84
84
 
85
- @vue/cli 4.5.13
85
+ @vue/cli 4.5.13