chore: 修改生命周期函数

This commit is contained in:
就眠儀式 2022-02-20 22:15:59 +08:00
parent 8e85bf818c
commit 8819a4845e
4 changed files with 2 additions and 54 deletions

View File

@ -16,13 +16,10 @@ import { ref } from 'vue'
export default { export default {
setup() { setup() {
const visible = ref(false) const visible = ref(false)
const changeVisible = function() { const changeVisible = function() {
visible.value = !visible.value; visible.value = !visible.value;
} }
return { return {
visible, visible,
changeVisible changeVisible
@ -54,19 +51,14 @@ import { ref } from 'vue'
export default { export default {
setup() { setup() {
const visible1 = ref(false) const visible1 = ref(false)
const changeVisible1 = function() { const changeVisible1 = function() {
visible1.value = !visible1.value; visible1.value = !visible1.value;
} }
const visible2 = ref(false) const visible2 = ref(false)
const changeVisible2 = function() { const changeVisible2 = function() {
visible2.value = !visible2.value; visible2.value = !visible2.value;
} }
return { return {
visible1, visible1,
visible2, visible2,
@ -94,14 +86,12 @@ import { layer } from "@layui/layer-vue"
export default { export default {
setup() { setup() {
const openDrawer = function() { const openDrawer = function() {
layer.drawer({ layer.drawer({
title: "标题", title: "标题",
content: "内容" content: "内容"
}) })
} }
return { return {
openDrawer openDrawer
} }
@ -129,7 +119,6 @@ import { layer } from "@layui/layer-vue"
export default { export default {
setup() { setup() {
const openTopDrawer = function() { const openTopDrawer = function() {
layer.drawer({ layer.drawer({
title: "标题", title: "标题",
@ -137,7 +126,6 @@ export default {
offset: "t" offset: "t"
}) })
} }
const openBottomDrawer = function() { const openBottomDrawer = function() {
layer.drawer({ layer.drawer({
title: "标题", title: "标题",
@ -145,7 +133,6 @@ export default {
offset: "b" offset: "b"
}) })
} }
const openLeftDrawer = function() { const openLeftDrawer = function() {
layer.drawer({ layer.drawer({
title: "标题", title: "标题",
@ -153,7 +140,6 @@ export default {
offset: "l" offset: "l"
}) })
} }
const openRightDrawer = function() { const openRightDrawer = function() {
layer.drawer({ layer.drawer({
title: "标题", title: "标题",
@ -161,7 +147,6 @@ export default {
offset: "r" offset: "r"
}) })
} }
return { return {
openTopDrawer, openTopDrawer,
openBottomDrawer, openBottomDrawer,

View File

@ -18,13 +18,10 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const visible1 = ref(false) const visible1 = ref(false)
const changeVisible1 = function() { const changeVisible1 = function() {
visible1.value = !visible1.value visible1.value = !visible1.value
} }
return { return {
visible1 visible1
}; };
@ -51,13 +48,10 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const visible2 = ref(false) const visible2 = ref(false)
const changeVisible2 = function() { const changeVisible2 = function() {
visible2.value = !visible2.value visible2.value = !visible2.value
} }
return { return {
visible2 visible2
}; };
@ -84,13 +78,10 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const visible3 = ref(false) const visible3 = ref(false)
const changeVisible3 = function() { const changeVisible3 = function() {
visible3.value = !visible3.value visible3.value = !visible3.value
} }
return { return {
visible3 visible3
}; };
@ -117,13 +108,10 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const visible4 = ref(false) const visible4 = ref(false)
const changeVisible4 = function() { const changeVisible4 = function() {
visible4.value = !visible4.value visible4.value = !visible4.value
} }
return { return {
visible4 visible4
}; };
@ -150,13 +138,10 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const visible8 = ref(false) const visible8 = ref(false)
const changeVisible8 = function() { const changeVisible8 = function() {
visible8.value = !visible8.value visible8.value = !visible8.value
} }
return { return {
visible8 visible8
}; };
@ -181,14 +166,11 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const type5 = ref(2) const type5 = ref(2)
const visible5 = ref(false) const visible5 = ref(false)
const changeVisible5 = function() { const changeVisible5 = function() {
visible5.value = !visible5.value visible5.value = !visible5.value
} }
return { return {
type5, type5,
visible5 visible5
@ -216,17 +198,14 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const visible6 = ref(false) const visible6 = ref(false)
const btn6 = [ const btn6 = [
{text:'确认', callback: ()=>{ alert("确认事件") }}, {text:'确认', callback: ()=>{ alert("确认事件") }},
{text:'取消', callback: ()=>{ alert("取消事件") }} {text:'取消', callback: ()=>{ alert("取消事件") }}
] ]
const changeVisible6 = function() { const changeVisible6 = function() {
visible6.value = !visible6.value visible6.value = !visible6.value
} }
return { return {
btn6, btn6,
visible6 visible6
@ -254,13 +233,10 @@ import { ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
const visible7 = ref(false) const visible7 = ref(false)
const changeVisible7 = function() { const changeVisible7 = function() {
visible7.value = !visible7.value visible7.value = !visible7.value
} }
return { return {
visible7 visible7
}; };
@ -287,21 +263,16 @@ import { layer } from "@layui/layer-vue"
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
export default { export default {
setup() { setup() {
let id = null; let id = null;
const open = function() { const open = function() {
id = layer.open({title:"标题",content:"内容", shade: false}) id = layer.open({title:"标题",content:"内容", shade: false})
} }
const close = function() { const close = function() {
layer.close(id) layer.close(id)
} }
const closeAll = function() { const closeAll = function() {
layer.closeAll() layer.closeAll()
} }
return { return {
open, open,
close, close,

View File

@ -15,9 +15,8 @@ import { layer } from "@layui/layer-vue"
export default { export default {
setup() { setup() {
const openMsg = function() { const openMsg = function() {
layer.msg("普通消息", { time: 100000 }) layer.msg("普通消息", { time: 1000 })
} }
return { return {
openMsg openMsg
@ -46,27 +45,21 @@ import { layer } from "@layui/layer-vue"
export default { export default {
setup() { setup() {
const openSuccess = function() { const openSuccess = function() {
layer.msg("成功消息", { icon : 1, time: 100000}) layer.msg("成功消息", { icon : 1, time: 100000})
} }
const openFailure = function() { const openFailure = function() {
layer.msg("失败消息", { icon : 2, time: 1000}) layer.msg("失败消息", { icon : 2, time: 1000})
} }
const openWarning = function() { const openWarning = function() {
layer.msg("警告消息", { icon : 3, time: 1000}) layer.msg("警告消息", { icon : 3, time: 1000})
} }
const openPrimary = function() { const openPrimary = function() {
layer.msg("详情消息", { icon : 4, time: 1000}) layer.msg("详情消息", { icon : 4, time: 1000})
} }
const openLoading = function() { const openLoading = function() {
layer.msg("加载消息", { icon : 16, time: 1000}) layer.msg("加载消息", { icon : 16, time: 1000})
} }
return { return {
openSuccess, openFailure, openWarning, openPrimary, openLoading openSuccess, openFailure, openWarning, openPrimary, openLoading
} }

View File

@ -30,8 +30,7 @@
"build:example": "vite build example", "build:example": "vite build example",
"lint:eslint": "eslint 'src/**/*.{vue,ts,tsx}' --fix", "lint:eslint": "eslint 'src/**/*.{vue,ts,tsx}' --fix",
"lint:prettier": "prettier --write \"src/**/*.{vue,ts}\"", "lint:prettier": "prettier --write \"src/**/*.{vue,ts}\"",
"prepare": "husky install", "postinstall": "husky install",
"postinstall": "npm run prepare",
"commit": "git-cz", "commit": "git-cz",
"commit:push": "git add . && git-cz && git push" "commit:push": "git add . && git-cz && git push"
}, },