[重构] button buttonGroup buttonContainer 组件, 未破坏功能的前提下改进代码

This commit is contained in:
就眠儀式
2021-11-16 11:30:29 +08:00
parent c8478662f8
commit f705122054
14 changed files with 234 additions and 218 deletions

View File

@@ -1,16 +1,11 @@
import { ref, onMounted, onUnmounted, Ref } from 'vue'
const x = undefined
// 案例详见 dropdown.vue
const useClickOutside = (elementRef: Ref<HTMLElement | null>) => {
// 设置一个导出值
const isClickOutside = ref(false)
// 给界面绑定上事件
const handler = (e: MouseEvent) => {
if (elementRef.value) {
// e.target 有可能是为 null 所以需要断言
if (elementRef.value.contains(e.target as HTMLElement)) {
// 判断目标节点是不是当前的节点
isClickOutside.value = false
} else {
isClickOutside.value = true