login.vue
1methods: { 2 handleSignUp(){ 3 try{ 4 this.signup( this.userInfo ) 5 }catch(e){ 6 console.log('失敗') 7 } 8 }, 9 ...mapActions('users', ['signup']) 10 }
store/user.js
1export const actions = { 2 login({ commit }, payload){ 3 4 }, 5 signup({ commit }, userInfo){ 6 // userInfo = {name: '', password: ''} 7 const email = userInfo.email 8 const password = userInfo.password 9 firebase.auth().createUserWithEmailAndPassword(email, password) 10 .catch(function(error){ 11 // throw new Error('アカウント作成に失敗しました。') 12 }) 13 // commit('setUserProfile', ) 14 } 15}
#やりたいこと
上記のように、アカウント失敗時にcatchで失敗時のやりたいこととしてthrow new Errorでエラーを投げて、それを、1枚目に書いたconsole.log(e.message)のところでキャッチしたいのですが、実際の動きはエラーが表示されるだけでconsole.log('失敗')のところが表示されません。
想定の通りに動かせるためにはどのようにしたらいいのでしょうか
あなたの回答
tips
プレビュー