11<template >
22 <!-- 本体部分 -->
3- <div :class =" ['vue-puzzle-vcode', {'show': show}]"
3+ <div :id =" id"
4+ :class =" ['vue-puzzle-vcode', {'show': show}]"
45 @mousedown =" onCloseMouseDown"
56 @mouseup =" onCloseMouseUp" >
67 <div class =" vue-auth-box"
@@ -81,6 +82,7 @@ export default {
8182 },
8283 /** 父级参数 **/
8384 props: {
85+ id: { type: String },
8486 canvasWidth: { type: Number , default: 310 }, // 主canvas的宽
8587 canvasHeight: { type: Number , default: 160 }, // 主canvas的高
8688 // 是否出现,由父级控制
@@ -105,12 +107,17 @@ export default {
105107
106108 /** 生命周期 **/
107109 mounted () {
110+ document .body .appendChild (this .$el );
108111 document .addEventListener (" mousemove" , this .onRangeMouseMove , false );
109112 document .addEventListener (" mouseup" , this .onRangeMouseUp , false );
113+ if (this .show ) {
114+ document .body .classList .add (" vue-puzzle-overflow" );
115+ }
110116 this .reset ();
111117 },
112118 beforeDestroy () {
113119 clearTimeout (this .timer1 );
120+ document .body .removeChild (this .$el );
114121 document .removeEventListener (" mousemove" , this .onRangeMouseMove , false );
115122 document .removeEventListener (" mouseup" , this .onRangeMouseUp , false );
116123 },
@@ -120,7 +127,10 @@ export default {
120127 show (newV ) {
121128 // 每次出现都应该重新初始化
122129 if (newV) {
130+ document .body .classList .add (" vue-puzzle-overflow" );
123131 this .reset ();
132+ } else {
133+ document .body .classList .remove (" vue-puzzle-overflow" );
124134 }
125135 }
126136 },
@@ -625,4 +635,7 @@ export default {
625635 }
626636 }
627637}
638+ .vue-puzzle-overflow {
639+ overflow : hidden !important ;
640+ }
628641 </style >
0 commit comments