質問編集履歴
3
現在作成中のコードを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,60 +10,320 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
下記に現在作成途中のアカウント新規登録画面のコード添付します。
|
14
|
+
|
15
|
+
|
16
|
+
|
13
|
-
```
|
17
|
+
```Signup.vue
|
18
|
+
|
14
|
-
|
19
|
+
<template>
|
20
|
+
|
21
|
+
<div class="signup">
|
22
|
+
|
23
|
+
<h2>新規登録</h2>
|
24
|
+
|
25
|
+
<input type="text" placeholder="Username" v-model="updateUsername">
|
26
|
+
|
27
|
+
<input type="text" placeholder="email" v-model="updateEmail">
|
28
|
+
|
29
|
+
<input type="password" placeholder="Password" v-model="updatePassword">
|
30
|
+
|
31
|
+
<button @click="signUp({email, password})">登録する</button>
|
32
|
+
|
33
|
+
</div>
|
34
|
+
|
35
|
+
</template>
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
<script>
|
40
|
+
|
15
|
-
|
41
|
+
import {
|
16
|
-
|
42
|
+
|
17
|
-
|
43
|
+
username,
|
44
|
+
|
18
|
-
|
45
|
+
email,
|
46
|
+
|
47
|
+
password
|
48
|
+
|
49
|
+
} from '../store/index.js'
|
50
|
+
|
51
|
+
import {
|
52
|
+
|
53
|
+
mapGetters
|
54
|
+
|
55
|
+
} from 'vuex'
|
56
|
+
|
57
|
+
import {
|
58
|
+
|
59
|
+
mapMutations
|
60
|
+
|
61
|
+
} from 'vuex'
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
export default {
|
66
|
+
|
67
|
+
name: 'Signup',
|
68
|
+
|
19
|
-
|
69
|
+
data() {
|
20
|
-
|
21
|
-
|
70
|
+
|
22
|
-
|
23
|
-
},
|
24
|
-
|
25
|
-
|
71
|
+
return {
|
26
|
-
|
72
|
+
|
27
|
-
|
73
|
+
username,
|
74
|
+
|
75
|
+
email,
|
76
|
+
|
77
|
+
password
|
28
78
|
|
29
79
|
}
|
30
80
|
|
81
|
+
},
|
82
|
+
|
83
|
+
methods: {
|
84
|
+
|
85
|
+
...mapMutations([
|
86
|
+
|
87
|
+
'signUp'
|
88
|
+
|
89
|
+
])
|
90
|
+
|
91
|
+
},
|
92
|
+
|
93
|
+
computed: {
|
94
|
+
|
95
|
+
...mapGetters([
|
96
|
+
|
97
|
+
'getUsername',
|
98
|
+
|
99
|
+
'getEmail',
|
100
|
+
|
101
|
+
'getPassword'
|
102
|
+
|
103
|
+
]),
|
104
|
+
|
105
|
+
updateUsername: {
|
106
|
+
|
107
|
+
get() {
|
108
|
+
|
109
|
+
return this.getUsername
|
110
|
+
|
111
|
+
},
|
112
|
+
|
113
|
+
set(value) {
|
114
|
+
|
115
|
+
this.$store.commit('updateUsername', value) //ここをmapMutationsを用いてthis.updateUsername(value)としたい。以下の2つの算出プロパティについても同じ。
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
},
|
120
|
+
|
121
|
+
updateEmail: {
|
122
|
+
|
123
|
+
get() {
|
124
|
+
|
125
|
+
return this.getEmail
|
126
|
+
|
127
|
+
},
|
128
|
+
|
129
|
+
set(value) {
|
130
|
+
|
131
|
+
this.$store.commit('updateEmail', value)
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
},
|
136
|
+
|
137
|
+
updatePassword: {
|
138
|
+
|
139
|
+
get() {
|
140
|
+
|
141
|
+
return this.getPassword
|
142
|
+
|
143
|
+
},
|
144
|
+
|
145
|
+
set(value) {
|
146
|
+
|
147
|
+
this.$store.commit('updatePassword', value)
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
}
|
152
|
+
|
31
153
|
}
|
32
154
|
|
33
155
|
}
|
34
156
|
|
157
|
+
</script>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<style scoped>
|
162
|
+
|
163
|
+
input {
|
164
|
+
|
165
|
+
display: flex;
|
166
|
+
|
167
|
+
flex-direction: column;
|
168
|
+
|
169
|
+
justify-content: center;
|
170
|
+
|
171
|
+
font: 16px/24px sans-serif;
|
172
|
+
|
173
|
+
width: 230px;
|
174
|
+
|
175
|
+
padding: 10px 0;
|
176
|
+
|
177
|
+
margin: 10px auto;
|
178
|
+
|
179
|
+
border: none;
|
180
|
+
|
181
|
+
border-bottom: 1.5px solid #1b2538;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
input:focus {
|
188
|
+
|
189
|
+
border-bottom: 1.5px solid #da3c41;
|
190
|
+
|
191
|
+
outline: none;
|
192
|
+
|
193
|
+
transition: .5s;
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
button {
|
200
|
+
|
201
|
+
color: #FFF;
|
202
|
+
|
203
|
+
background-color: #1da1f3;
|
204
|
+
|
205
|
+
border-radius: 20px;
|
206
|
+
|
207
|
+
display: inline-block;
|
208
|
+
|
209
|
+
margin: 10px auto;
|
210
|
+
|
211
|
+
height: 40px;
|
212
|
+
|
213
|
+
width: 120px;
|
214
|
+
|
215
|
+
font-size: 16px;
|
216
|
+
|
217
|
+
border: none;
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
button:active {
|
224
|
+
|
225
|
+
background-color: #36c;
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
button:focus {
|
232
|
+
|
233
|
+
outline: 0px;
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
</style>
|
238
|
+
|
35
239
|
```
|
36
240
|
|
37
|
-
|
241
|
+
|
38
|
-
|
39
|
-
|
40
|
-
|
242
|
+
|
41
|
-
```
|
243
|
+
```index.js
|
244
|
+
|
42
|
-
|
245
|
+
import Vue from 'vue'
|
246
|
+
|
247
|
+
import Vuex from 'vuex'
|
248
|
+
|
249
|
+
import firebase from 'firebase'
|
250
|
+
|
251
|
+
|
252
|
+
|
43
|
-
|
253
|
+
Vue.use(Vuex)
|
254
|
+
|
255
|
+
|
256
|
+
|
44
|
-
|
257
|
+
export default new Vuex.Store({
|
258
|
+
|
45
|
-
|
259
|
+
state: {
|
260
|
+
|
46
|
-
|
261
|
+
username: '',
|
262
|
+
|
47
|
-
|
263
|
+
email: '',
|
48
|
-
|
49
|
-
|
264
|
+
|
50
|
-
|
51
|
-
|
265
|
+
password: ''
|
52
|
-
|
266
|
+
|
53
|
-
|
267
|
+
},
|
54
|
-
|
268
|
+
|
55
|
-
|
269
|
+
getters: {
|
270
|
+
|
56
|
-
|
271
|
+
getUsername: state => state.username,
|
272
|
+
|
273
|
+
getEmail: state => state.email,
|
274
|
+
|
275
|
+
getPassword: state => state.password
|
276
|
+
|
277
|
+
},
|
278
|
+
|
279
|
+
mutations: {
|
280
|
+
|
281
|
+
signUp({ email, password }) {
|
282
|
+
|
283
|
+
firebase
|
284
|
+
|
285
|
+
.auth()
|
286
|
+
|
287
|
+
.createUserWithEmailAndPassword(email, password)
|
288
|
+
|
289
|
+
.then(user => {
|
290
|
+
|
291
|
+
alert('Create account: ' + user.user.email)
|
292
|
+
|
293
|
+
})
|
294
|
+
|
295
|
+
.catch(error => {
|
296
|
+
|
297
|
+
alert(error.message)
|
298
|
+
|
299
|
+
})
|
300
|
+
|
301
|
+
},
|
302
|
+
|
303
|
+
updateUsername(state, value) {
|
304
|
+
|
305
|
+
state.username = value
|
306
|
+
|
307
|
+
},
|
308
|
+
|
57
|
-
|
309
|
+
updateEmail(state, value) {
|
310
|
+
|
311
|
+
state.email = value
|
312
|
+
|
313
|
+
},
|
314
|
+
|
315
|
+
updatePassword(state, value) {
|
316
|
+
|
317
|
+
state.password = value
|
58
318
|
|
59
319
|
}
|
60
320
|
|
61
|
-
}
|
321
|
+
},
|
322
|
+
|
62
|
-
|
323
|
+
actions: {},
|
324
|
+
|
325
|
+
modules: {}
|
326
|
+
|
63
|
-
}
|
327
|
+
})
|
64
328
|
|
65
329
|
```
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
のようなイメージでj修正したいです。
|
2
崩れを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,7 +44,9 @@
|
|
44
44
|
|
45
45
|
message: {
|
46
46
|
|
47
|
-
...mapMutations(['updateMessage'])
|
47
|
+
...mapMutations(['updateMessage'])
|
48
|
+
|
49
|
+
get() {
|
48
50
|
|
49
51
|
return this.$store.state.obj.message
|
50
52
|
|
1
具体的なコードを記述
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,3 +7,61 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
ここで質問ですが、mapMutationsを使ってcommitの部分を書き換えることは可能でしょうか?
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```Vue.js
|
14
|
+
|
15
|
+
computed: {
|
16
|
+
|
17
|
+
message: {
|
18
|
+
|
19
|
+
get() {
|
20
|
+
|
21
|
+
return this.$store.state.obj.message
|
22
|
+
|
23
|
+
},
|
24
|
+
|
25
|
+
set(value) {
|
26
|
+
|
27
|
+
this.$store.commit('updateMessage', value)
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
上記の部分を
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```Vue.js
|
42
|
+
|
43
|
+
computed: {
|
44
|
+
|
45
|
+
message: {
|
46
|
+
|
47
|
+
...mapMutations(['updateMessage']) get() {
|
48
|
+
|
49
|
+
return this.$store.state.obj.message
|
50
|
+
|
51
|
+
},
|
52
|
+
|
53
|
+
set(value) {
|
54
|
+
|
55
|
+
this.updateMessage(value)
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
のようなイメージでj修正したいです。
|