Skip to content

Commit d0a152e

Browse files
committed
support vue 3.0
1 parent ee4deb1 commit d0a152e

13 files changed

+1120
-1052
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
env: {
44
node: true
55
},
6-
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
6+
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'],
77
parserOptions: {
88
parser: 'babel-eslint'
99
},

dist/VueFinalModal.esm.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.

dist/VueFinalModal.esm.js.map

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

dist/VueFinalModal.umd.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.

dist/VueFinalModal.umd.js.map

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/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
env: {
44
node: true
55
},
6-
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
6+
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'],
77
parserOptions: {
88
parser: 'babel-eslint'
99
},

example/package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,26 @@
1010
"dependencies": {
1111
"core-js": "^3.6.5",
1212
"tailwindcss": "^1.4.6",
13-
"vue": "^2.6.11",
13+
"vue": "^3.0.0",
1414
"vue-final-modal": "link:.."
1515
},
1616
"devDependencies": {
17-
"@vue/cli-plugin-babel": "~4.4.0",
18-
"@vue/cli-plugin-eslint": "~4.4.0",
19-
"@vue/cli-service": "~4.4.0",
17+
"@vue/cli-plugin-babel": "4.5.6",
18+
"@vue/cli-plugin-eslint": "4.5.6",
19+
"@vue/cli-service": "4.5.6",
20+
"@vue/compiler-sfc": "^3.0.0",
2021
"@vue/eslint-config-prettier": "^6.0.0",
2122
"babel-eslint": "^10.1.0",
2223
"eslint": "^6.7.2",
2324
"eslint-plugin-prettier": "^3.1.3",
24-
"eslint-plugin-vue": "^6.2.2",
25+
"eslint-plugin-vue": "^7.0.0-beta.3",
2526
"lint-staged": "^9.5.0",
27+
<<<<<<< HEAD
2628
"prettier": "^1.19.1",
2729
"vue-template-compiler": "^2.6.11"
30+
=======
31+
"prettier": "^1.19.1"
32+
>>>>>>> support vue 3.0
2833
},
2934
"gitHooks": {
3035
"pre-commit": "lint-staged"

example/src/main.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import Vue from 'vue'
1+
import { createApp } from 'vue'
22
import App from './App.vue'
33
import './assets/css/tailwind.css'
44
import components from '@/components/index.js'
55

66
import { VueFinalModal } from 'vue-final-modal'
77

8-
Vue.component('VueFinalModal', VueFinalModal)
8+
const app = createApp(App)
9+
10+
app.component('VueFinalModal', VueFinalModal)
911

1012
Object.keys(components).forEach(name => {
11-
Vue.component(name, components[name])
13+
app.component(name, components[name])
1214
})
1315

14-
Vue.config.productionTip = false
15-
16-
new Vue({
17-
render: h => h(App)
18-
}).$mount('#app')
16+
app.mount('#app')

example/yarn.lock

Lines changed: 425 additions & 94 deletions
Large diffs are not rendered by default.

lib/VueFinalModal.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
v-show="visibility.modal"
3434
class="vfm__container vfm--absolute vfm--inset"
3535
:class="[classes, { 'vfm--cursor-pointer': clickToClose }]"
36-
@click="clickToClose && $emit('input', false)"
36+
@click="clickToClose && $emit('update:modelValue', false)"
3737
>
3838
<slot name="content-before" />
3939
<slot name="content">
@@ -78,7 +78,7 @@ const CLASS_TYPES = [String, Object, Array]
7878
export default {
7979
name: 'VueFinalModal',
8080
props: {
81-
value: { type: Boolean, default: false },
81+
modelValue: { type: Boolean, default: false },
8282
ssr: { type: Boolean, default: true },
8383
classes: { type: CLASS_TYPES, default: '' },
8484
overlayClass: { type: CLASS_TYPES, default: '' },
@@ -93,6 +93,13 @@ export default {
9393
zIndexBase: { type: [String, Number], default: 1000 },
9494
zIndex: { type: [Boolean, String, Number], default: false }
9595
},
96+
emits: [
97+
'update:modelValue',
98+
'before-open',
99+
'opened',
100+
'before-close',
101+
'closed'
102+
],
96103
data: () => ({
97104
modalStackIndex: null,
98105
visible: false,
@@ -124,15 +131,15 @@ export default {
124131
}
125132
},
126133
watch: {
127-
value(value) {
134+
modelValue(value) {
128135
this.mounted()
129136
if (!value) {
130137
this.close()
131138
}
132139
},
133140
lockScroll: 'handleLockScroll',
134141
hideOverlay(value) {
135-
if (this.value && !value) {
142+
if (this.modelValue && !value) {
136143
this.visibility.overlay = true
137144
}
138145
},
@@ -146,13 +153,13 @@ export default {
146153
mounted() {
147154
this.mounted()
148155
},
149-
beforeDestroy() {
156+
beforeUnmount() {
150157
this.close()
151158
this.$el.remove()
152159
},
153160
methods: {
154161
mounted() {
155-
if (this.value) {
162+
if (this.modelValue) {
156163
let target = this.getAttachElement()
157164
if (target || this.attach === false) {
158165
this.attach !== false && target.appendChild(this.$el)

0 commit comments

Comments
 (0)