Skip to content

Commit 5f5498e

Browse files
committed
1.0.6, 把DOM挂载到了body下面
1 parent 730eab3 commit 5f5498e

File tree

9 files changed

+54
-8
lines changed

9 files changed

+54
-8
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@vue/babel-preset-jsx"]
3+
}

dist/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue';
2-
import App from './src/app.vue';
2+
import App from './src/app';
33

44
Vue.config.productionTip = false;
55

example/src/app.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ export default {
2121
components: {
2222
AuthModelMy
2323
},
24+
mounted() {
25+
// AuthModelMy({
26+
// show: this.show
27+
// });
28+
},
2429
methods: {
2530
onTest() {
2631
this.show = true;
2732
},
2833
onTestClose() {
34+
console.log("出发:", this.show);
2935
this.show = false;
3036
}
3137
}

example/src/assets/1.jpg

-178 KB
Loading

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-puzzle-vcode",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "vue 滑动拼图验证码",
55
"main": "dist/main.js",
66
"scripts": {
@@ -33,6 +33,8 @@
3333
"@babel/plugin-transform-runtime": "^7.2.0",
3434
"@babel/polyfill": "^7.0.0",
3535
"@babel/runtime": "^7.2.0",
36+
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.3",
37+
"@vue/babel-preset-jsx": "^1.0.0-beta.3",
3638
"autoprefixer": "^9.4.3",
3739
"babel-loader": "^8.0.4",
3840
"babel-plugin-import": "^1.11.0",

src/app.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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>

src/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
1-
import App from './app.vue';
2-
export default App;
1+
// import Vue from 'vue';
2+
import Component from './app.vue';
3+
4+
export default Component;
5+
// export default new Vue({
6+
// props: {
7+
// show: { type: Boolean, defalut: false },
8+
// },
9+
// beforeCreate() {
10+
// const body = document.body;
11+
// const bindPhone = document.getElementById('vue-puzzle-code-dom') || document.createElement('div');
12+
13+
// bindPhone.setAttribute('id', 'vue-puzzle-code-temp');
14+
// body.appendChild(bindPhone);
15+
// },
16+
// render: h => {
17+
// return h(Component, {
18+
// props: {
19+
// id: 'vue-puzzle-code-dom',
20+
// show: show,
21+
// },
22+
// });
23+
// },
24+
// }).$mount('#vue-puzzle-code-temp');

webpack.production.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
publicPath: '/dist/',
1515
library: 'vue-puzzle-vcode',
1616
libraryTarget: 'umd',
17-
umdNamedDefine: true,
17+
// umdNamedDefine: true,
1818
},
1919
externals: {
2020
vue: 'vue',
@@ -28,7 +28,7 @@ module.exports = {
2828
},
2929
{
3030
// .js .jsx用babel解析
31-
test: /\.js?$/,
31+
test: /\.(js|jsx)?$/,
3232
use: ['babel-loader'],
3333
include: path.resolve(__dirname, 'src'),
3434
},

0 commit comments

Comments
 (0)