File tree Expand file tree Collapse file tree 3 files changed +101
-16
lines changed Expand file tree Collapse file tree 3 files changed +101
-16
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <form-helper >
4
- <div slot =" form-header" >
5
- <h3 >This is the title of a form</h3 >
6
- <p >This is some info about the form</p >
7
- </div >
8
- <div slot =" form-fields" >
9
- <input type =" text" placeholder =" name" required />
10
- <input type =" password" placeholder =" password" required />
11
- </div >
12
- <div slot =" form-controls" >
13
- <button v-on:click =" handleSubmit" >Submit</button >
14
- </div >
15
- </form-helper >
3
+ <keep-alive >
4
+ <component v-bind:is =" component" ></component >
5
+ </keep-alive >
6
+ <button v-on:click =" component = 'form-one'" >Show form one</button >
7
+ <button v-on:click =" component = 'form-two'" >Show form two</button >
16
8
</div >
17
9
</template >
18
10
19
11
<script >
20
12
// Imports
21
- import formHelper from ' ./components/formHelper.vue'
13
+ import formOne from ' ./components/formOne.vue' ;
14
+ import formTwo from ' ./components/formTwo.vue' ;
22
15
23
16
export default {
24
17
components: {
25
- ' form-helper' : formHelper
18
+ ' form-one' : formOne,
19
+ ' form-two' : formTwo
26
20
},
27
21
data () {
28
22
return {
29
-
23
+ component : ' form-one '
30
24
}
31
25
},
32
26
methods: {
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ <form-helper >
4
+ <div slot =" form-header" >
5
+ <h3 >Form One - Contact Us</h3 >
6
+ <p >Fill in this form to contact us</p >
7
+ </div >
8
+ <div slot =" form-fields" >
9
+ <input type =" text" placeholder =" name" required />
10
+ <label >Your Message:</label >
11
+ <textarea ></textarea >
12
+ </div >
13
+ <div slot =" form-controls" >
14
+ <button v-on:click =" handleSubmit" >Send</button >
15
+ </div >
16
+ </form-helper >
17
+ </div >
18
+ </template >
19
+
20
+ <script >
21
+ // Imports
22
+ import formHelper from ' ./formHelper.vue'
23
+
24
+ export default {
25
+ components: {
26
+ ' form-helper' : formHelper
27
+ },
28
+ data () {
29
+ return {
30
+
31
+ }
32
+ },
33
+ methods: {
34
+ handleSubmit : function (){
35
+ alert (' thanks for submitting form one & contacting us' );
36
+ }
37
+ }
38
+ }
39
+ </script >
40
+
41
+ <style >
42
+ body {
43
+ margin : 0 ;
44
+ font-family : ' Nunito SemiBold' ;
45
+ }
46
+ </style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ <form-helper >
4
+ <div slot =" form-header" >
5
+ <h3 >Form Two - Log In</h3 >
6
+ <p >Enter your details to log-in</p >
7
+ </div >
8
+ <div slot =" form-fields" >
9
+ <input type =" text" placeholder =" username" required />
10
+ <input type =" password" placeholder =" password" required />
11
+ </div >
12
+ <div slot =" form-controls" >
13
+ <button v-on:click =" handleSubmit" >Login</button >
14
+ </div >
15
+ </form-helper >
16
+ </div >
17
+ </template >
18
+
19
+ <script >
20
+ // Imports
21
+ import formHelper from ' ./formHelper.vue'
22
+
23
+ export default {
24
+ components: {
25
+ ' form-helper' : formHelper
26
+ },
27
+ data () {
28
+ return {
29
+
30
+ }
31
+ },
32
+ methods: {
33
+ handleSubmit : function (){
34
+ alert (' thanks for logging in (form two)' );
35
+ }
36
+ }
37
+ }
38
+ </script >
39
+
40
+ <style >
41
+ body {
42
+ margin : 0 ;
43
+ font-family : ' Nunito SemiBold' ;
44
+ }
45
+ </style >
You can’t perform that action at this time.
0 commit comments