fix: v-access指令无法控制元素展示隐藏

This commit is contained in:
cwsong4 2024-10-10 16:48:41 +08:00
parent cfa522a3d3
commit dc0fa4b47d

View File

@ -13,7 +13,10 @@ export default function createDirective(useAccess) {
beforeMount(el) {
const ctx = {};
ctx.watch = (path) => {
el._display = el._display || el.style.display;
// el._display = el._display || el.style.display; // 这种只能获取到行内样式 会导致保存不了组件加载时的初始display
if (!el._display) {
el._display = window.getComputedStyle(el).display
}
const access = useAccess(path);
setDisplay(el, access);
return watch(access, () => {