File tree 4 files changed +12069
-0
lines changed
4 files changed +12069
-0
lines changed Original file line number Diff line number Diff line change
1
+ .dialog {
2
+ position : absolute;
3
+ left : 50% ;
4
+ top : 50% ;
5
+ transform : translate (-50% , -50% );
6
+ background : # fff ;
7
+ border-radius : 2px ;
8
+ box-shadow : 0 1px 3px rgba (0 , 0 , 0 , .3 );
9
+ box-sizing : border-box;
10
+ min-width : 300px ;
11
+ }
12
+
13
+ .dialog-header {
14
+ padding : 20px 20px 10px ;
15
+ }
16
+
17
+ .dialog-close {
18
+ position : absolute;
19
+ top : 10px ;
20
+ right : 10px ;
21
+ cursor : pointer;
22
+ font-size : 16px ;
23
+ }
24
+
25
+ .dialog-body {
26
+ padding : 30px 20px ;
27
+ color : # 606266 ;
28
+ font-size : 14px ;
29
+ word-break : break-all;
30
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
+ < title > Document</ title >
8
+ < link rel ="stylesheet " href ="./css/dialog.css " />
9
+ </ head >
10
+
11
+ < body >
12
+
13
+ < div id ="app ">
14
+ < button @click ="visible=!visible "> 按钮</ button >
15
+
16
+ < kkb-dialog :title ="title " :visible.sync ="visible " @open ="open " @close ="close ">
17
+ < span > 这是一段信息</ span >
18
+ </ kkb-dialog >
19
+ </ div >
20
+
21
+ < script src ="./js/vue.js "> </ script >
22
+ < script src ="./js/dialog.js "> </ script >
23
+ < script >
24
+ new Vue ( {
25
+ el : '#app' ,
26
+ data : {
27
+ title : '新的标题' ,
28
+ visible : true
29
+ } ,
30
+ methods : {
31
+ open ( ) {
32
+ console . log ( '打开了' ) ;
33
+ } ,
34
+
35
+ close ( ) {
36
+ console . log ( '关闭了' ) ;
37
+ }
38
+ }
39
+ } ) ;
40
+ </ script >
41
+ </ body >
42
+
43
+ </ html >
Original file line number Diff line number Diff line change
1
+ Vue . component ( 'kkb-dialog' , {
2
+ props : {
3
+ visible : Boolean ,
4
+ title : String ,
5
+ } ,
6
+ data ( ) {
7
+ return { } ;
8
+ } ,
9
+ watch : {
10
+ visible : function ( val ) {
11
+ val ? this . $emit ( "open" ) : this . $emit ( "close" ) ;
12
+
13
+ }
14
+ } ,
15
+ methods :{
16
+ close ( ) {
17
+ this . $emit ( 'update:visible' , false ) ;
18
+ }
19
+ } ,
20
+ template : `
21
+ <div class="dialog" v-show="visible">
22
+ <div class="dialog-header">
23
+ <span class="dialog-title">提示</span>
24
+ <i class="dialog-close" @click="close">x</i>
25
+ </div>
26
+ <div class="dialog-body">
27
+ <slot></slot>
28
+ </div>
29
+ </div>
30
+ `
31
+ } ) ;
You can’t perform that action at this time.
0 commit comments