11<template >
2- <div class =" nut-luckycard" :style =" {height:height+ 'px',width:width+ 'px'}" >
3- <div class =" nut-content" v-html =" content" :style =" {backgroundColor:backgroundColor,fontSize:fontSize+ 'px'}" ></div >
4- </div >
2+ <div class =" nut-luckycard" :style =" { height: height + 'px', width: width + 'px' }" >
3+ <div class =" nut-content" v-html =" content" :style =" { backgroundColor: backgroundColor, fontSize: fontSize + 'px' }" ></div >
4+ </div >
55</template >
66
77<script >
88import LuckyCard from ' ./luckycard.js' ;
99export default {
10- name: ' nut-luckycard' ,
11- props: {
12- content: {
13- type: String ,
14- default: ' '
15- },
16- height: {
17- type: [String , Number ],
18- default: 50
19- },
20- width: {
21- type: [String , Number ],
22- default: 300
23- },
24- coverColor: {
25- type: String ,
26- default: ' #C5C5C5'
27- },
28- coverImg: {
29- type: String ,
30- default: ' '
31- },
32- fontSize: {
33- type: [String , Number ],
34- default: 20
35- },
36- backgroundColor: {
37- type: String ,
38- default: ' #FFFFFF'
39- },
40- ratio: {
41- type: [String , Number ],
42- default: 0.5
43- }
10+ name: ' nut-luckycard' ,
11+ props: {
12+ content: {
13+ type: String ,
14+ default: ' '
15+ },
16+ height: {
17+ type: [String , Number ],
18+ default: 50
19+ },
20+ width: {
21+ type: [String , Number ],
22+ default: 300
23+ },
24+ coverColor: {
25+ type: String ,
26+ default: ' #C5C5C5'
27+ },
28+ coverImg: {
29+ type: String ,
30+ default: ' '
4431 },
45- data () {
46- return {};
32+ fontSize: {
33+ type: [String , Number ],
34+ default: 20
4735 },
48- methods: {
36+ backgroundColor: {
37+ type: String ,
38+ default: ' #FFFFFF'
4939 },
50- mounted (){
51- this .$nextTick (()=> {
52- const _vm = this ;
53- LuckyCard ({
54- scratchDiv: this .$el ,
55- coverColor: this .coverColor ,
56- coverImg: this .coverImg ,
57- ratio: Number (this .ratio ),
58- callback : function (){
59- // console.log(this);
60- // this.clearCover();
61- _vm .$emit (' open' ,this );
62- }
63- })
64- })
40+ ratio: {
41+ type: [String , Number ],
42+ default: 0.5
6543 }
66- }
44+ },
45+ data () {
46+ return {
47+ luckcard: null
48+ };
49+ },
50+ methods: {
51+ clearCover () {
52+ console .log (this .luckcard );
53+ this .luckcard .clearCover ();
54+ }
55+ },
56+ mounted () {
57+ this .$nextTick (() => {
58+ const _vm = this ;
59+ this .luckcard = LuckyCard ({
60+ scratchDiv: this .$el ,
61+ coverColor: this .coverColor ,
62+ coverImg: this .coverImg ,
63+ ratio: Number (this .ratio ),
64+ callback : function () {
65+ // console.log(this);
66+ this .clearCover ();
67+ _vm .$emit (' open' , this );
68+ }
69+ });
70+ });
71+ }
72+ };
6773 </script >
6874<style lang="scss">
69- .nut-luckycard {
70- position : relative ;
71- .nut-cover {
72- position :absolute ;
73- top :0 ;
74- left :0 ;
75- }
76- .nut-content {
77- display :flex ;
78- align-items : center ;
79- justify-content : center ;
80- height :100% ;
81- width :100% ;
82- line-height : 100% ;
83- user-select :none ;
84- }
75+ .nut-luckycard {
76+ position : relative ;
77+ .nut-cover {
78+ position : absolute ;
79+ top : 0 ;
80+ left : 0 ;
81+ }
82+ .nut-content {
83+ display : flex ;
84+ align-items : center ;
85+ justify-content : center ;
86+ height : 100% ;
87+ width : 100% ;
88+ line-height : 100% ;
89+ user-select : none ;
90+ }
8591}
86- </style >
92+ </style >
0 commit comments