File tree Expand file tree Collapse file tree 11 files changed +154
-0
lines changed Expand file tree Collapse file tree 11 files changed +154
-0
lines changed Original file line number Diff line number Diff line change 1
1
< div id ="examples ">
2
+ < h2 > Setting panel openOn</ h2 >
2
3
< p >
3
4
Open panels on the left, right, top or bottom side using the < code > openOn</ code > option:
4
5
</ p >
Original file line number Diff line number Diff line change
1
+ <template src="./template.html ">
2
+ </template >
3
+
4
+ <script >
5
+ export default {
6
+ name: ' examples-passing-data' ,
7
+ data () {
8
+ return {
9
+ name: null ,
10
+ age: null
11
+ }
12
+ },
13
+ methods: {
14
+ showPanel () {
15
+ const panelResult = this .$showPanel ({
16
+ component: ' panel-2' ,
17
+ width: 600 ,
18
+ openOn: ' right' ,
19
+ props: {
20
+ age: this .age
21
+ }
22
+ });
23
+
24
+ panelResult .promise
25
+ .then (result => {
26
+ this .name = result;
27
+ });
28
+ }
29
+ }
30
+ };
31
+ </script >
32
+
33
+ <style lang="less">
34
+ </style >
Original file line number Diff line number Diff line change
1
+ < div id ="examples ">
2
+ < h2 > Passing Data</ h2 >
3
+ < p >
4
+ You can pass data to your components by using the < code > props</ code > property:
5
+ </ p >
6
+ < pre class ="highlight ">
7
+ const panelResult = this.$showPanel({
8
+ component: "panel-2",
9
+ props: {
10
+ age: {{ age }}
11
+ }
12
+ });</ pre >
13
+ < p >
14
+ And you can receive data from your panel by using the < code > promise</ code > property of the < code > PanelResult</ code > object:
15
+ </ p >
16
+ < pre class ="highlight ">
17
+ const panelResult = this.$showPanel({
18
+ component: "panel-2",
19
+ props: {
20
+ age: {{ age }}
21
+ }
22
+ });
23
+
24
+ panelResult.promise
25
+ .then(result => {
26
+ //result is the value passed from your component calling < strong > this.$emit('close-panel', //some value);</ strong >
27
+ });</ pre >
28
+ < p >
29
+ In your panel component you just need to call < code > this.$emit('close-panel')</ code > to close your panel:
30
+ </ p >
31
+ < pre class ="highlight ">
32
+ //in your component's code ("panel-2" in this example)
33
+
34
+ {
35
+ props: {
36
+ age: {
37
+ type: String,
38
+ required: true
39
+ }
40
+ },
41
+ data() {
42
+ name : null
43
+ },
44
+ methods: {
45
+ closePanel() {
46
+ this.$emit('closePanel', {});
47
+ }
48
+ }
49
+ }</ pre >
50
+ < h2 > Example</ h2 >
51
+ < div class ="form-group ">
52
+ < label > What's your age?</ label >
53
+ < input type ="number " class ="form-control " v-model ="age " />
54
+ </ div >
55
+ < div class ="form-group " v-if ="name ">
56
+ Your name is {{ name }}
57
+ </ div >
58
+ < button @click.prevent ="showPanel ">
59
+ Show Panel
60
+ </ button >
61
+ </ div >
Original file line number Diff line number Diff line change 1
1
< div id ="examples ">
2
+ < h2 > Setting panel width</ h2 >
2
3
< p >
3
4
Open panels on the left, right, top or bottom side using the < code > openOn</ code > option:
4
5
</ p >
Original file line number Diff line number Diff line change
1
+ <template src="./template.html ">
2
+ </template >
3
+
4
+ <script >
5
+ export default {
6
+ name: ' panel-2' ,
7
+ props: {
8
+ age: {
9
+ type: String ,
10
+ required: true
11
+ }
12
+ },
13
+ data () {
14
+ return {
15
+ name: null
16
+ }
17
+ },
18
+ methods: {
19
+ closePanel () {
20
+ this .$emit (' closePanel' , this .name );
21
+ }
22
+ }
23
+ };
24
+ </script >
25
+
26
+ <style lang="less">
27
+ #panel-2 {
28
+ padding : 45px ;
29
+ }
30
+ </style >
Original file line number Diff line number Diff line change
1
+ < div id ="panel-2 ">
2
+ You are {{ age }} years old!
3
+
4
+ < div class ="form-group ">
5
+ < label > What's your name?</ label >
6
+ < input type ="text " class ="form-control " v-model ="name " />
7
+ </ div >
8
+ < button @click.prevent ="closePanel ">
9
+ Close Panel
10
+ </ button >
11
+ </ div >
Original file line number Diff line number Diff line change @@ -64,4 +64,7 @@ <h2>Panel Result</h2>
64
64
});
65
65
}
66
66
}</ pre >
67
+ < p >
68
+ < router-link :to ="{ name : 'ExamplesPassingData' } "> Learn more about the passing data here.</ router-link >
69
+ </ p >
67
70
</ div >
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export default {
21
21
padding-top : 20px ;
22
22
position : sticky ;
23
23
top : 0 ;
24
+ height : 300px ;
24
25
25
26
ul {
26
27
margin : 0 ;
Original file line number Diff line number Diff line change 35
35
Width
36
36
</ router-link >
37
37
</ li >
38
+ < li >
39
+ < router-link activeClass ="active " :to ="{ name : 'ExamplesPassingData' } ">
40
+ Passing Data
41
+ </ router-link >
42
+ </ li >
38
43
</ ul >
39
44
</ li >
40
45
</ ul >
Original file line number Diff line number Diff line change @@ -4,12 +4,14 @@ import VueFriendlyIframe from '../src/index';
4
4
import App from './components/App' ;
5
5
import Sidebar from './components/Sidebar' ;
6
6
import Panel1 from './components/Panel1' ;
7
+ import Panel2 from './components/Panel2' ;
7
8
import router from './router' ;
8
9
9
10
Vue . use ( VueFriendlyIframe ) ;
10
11
11
12
Vue . component ( 'sidebar' , Sidebar ) ;
12
13
Vue . component ( 'panel-1' , Panel1 ) ;
14
+ Vue . component ( 'panel-2' , Panel2 ) ;
13
15
14
16
new Vue ( {
15
17
template : '<App></App>' ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import PanelResult from './components/PanelResult';
8
8
import Examples from './components/Examples' ;
9
9
import ExamplesOpenOn from './components/Examples-openOn' ;
10
10
import ExamplesWidth from './components/Examples-width' ;
11
+ import ExamplesPassingData from './components/Examples-passingData' ;
11
12
12
13
Vue . use ( VueRouter ) ;
13
14
@@ -46,6 +47,10 @@ const routes = [{
46
47
name : 'ExamplesWidth' ,
47
48
path : '/examples/width' ,
48
49
component : ExamplesWidth ,
50
+ } , {
51
+ name : 'ExamplesPassingData' ,
52
+ path : '/examples/passing-data' ,
53
+ component : ExamplesPassingData ,
49
54
} ]
50
55
} ] ;
51
56
You can’t perform that action at this time.
0 commit comments