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

回答編集履歴

1

ソースの追加

2019/03/07 04:30

投稿

sauzar18
sauzar18

スコア163

answer CHANGED
@@ -3,4 +3,95 @@
3
3
  たとえば最初のフォームで入力値を自分はVue.jsのv-modelで次の確認モーダルウィンドウへ
4
4
  双方向のバインディングをします。で、最初のフォームのボタンを押したときにモーダルウィンドウになるタグに
5
5
  クラスを付与して表示させるとかですね。
6
- ご参考までに。
6
+ ご参考までに。
7
+
8
+ 簡易的なものですが、こんな感じです。
9
+ ```html
10
+ <html lang="ja">
11
+ <head>
12
+ <meta charset="UTF-8">
13
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
14
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
15
+ <title>Document</title>
16
+ <style>
17
+ * {
18
+ padding: 0;
19
+ margin: 0;
20
+ }
21
+ .st-modal {
22
+ position: fixed;
23
+ left: 0;
24
+ right: 0;
25
+ top: 120px;
26
+ width: 320px;
27
+ max-width: 0;
28
+ margin: 0 auto;
29
+ box-shadow: 0 0 6px rgba(0,0,0,0.16);
30
+ transition: 0.2s all;
31
+ visibility: visible;
32
+ overflow: hidden;
33
+ }
34
+ .st-modal.active {
35
+ max-width: 320px;
36
+ visibility: initial;
37
+ overflow: initial;
38
+ padding: 20px;
39
+ background-color: #efefef;
40
+ }
41
+ dl{
42
+ display: flex;
43
+ align-items: center;
44
+ }
45
+ </style>
46
+ </head>
47
+ <body>
48
+ <div id="app">
49
+ <form>
50
+ <div class="form">
51
+ <input
52
+ type="text"
53
+ v-model="name"
54
+ required
55
+ aria-required="true"
56
+ >
57
+ <button
58
+ v-if="name"
59
+ type="button"
60
+ @click="isActive = true"
61
+ >
62
+ 確認
63
+ </button>
64
+ <p v-else>{{ isMessage() }}</p>
65
+ </div>
66
+ <div
67
+ :class="{ active: isActive }"
68
+ class="st-modal"
69
+ >
70
+ <dl>
71
+ <dt>お名前:</dt>
72
+ <dd>{{ name }}</dd>
73
+ </dl>
74
+ <button type="submit">
75
+ 送信
76
+ </button>
77
+ </div>
78
+ </form>
79
+ </div>
80
+ <script src="https://cdn.jsdelivr.net/npm/vue"></script>
81
+ <script>
82
+ const app = new Vue({
83
+ el: '#app',
84
+ data: {
85
+ name: '',
86
+ isActive: false
87
+ },
88
+ methods: {
89
+ isMessage: function () {
90
+ if (!this.name) return 'お名前が入力されていません。'
91
+ }
92
+ }
93
+ })
94
+ </script>
95
+ </body>
96
+ </html>
97
+ ```