st-common-ui-vue3
Version:
小尾巴通用 Vue3 UI 组件库
2 lines (1 loc) • 704 B
JavaScript
;const e=require("vue"),n=require("../../node_modules/.pnpm/@vueuse_core@12.0.0_typescript@5.6.2/node_modules/@vueuse/core/index.js"),c=e.defineComponent({name:"StWatchWidth",__name:"StWatchWidth",props:{strategy:{default:"self"},widthChangeHandler:{type:Function,default:()=>{}},immediate:{type:Boolean,default:!0}},setup(t){const a=e.ref(null),{width:d}=n.useElementSize(a),{width:s}=n.useWindowSize();return e.watch(()=>t.strategy==="self"?d.value:s.value,i=>t.widthChangeHandler(i),{immediate:t.immediate}),(i,h)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"stWatchWidthRef",ref:a,class:"st-watch-width"},[e.renderSlot(i.$slots,"default",{},void 0,!0)],512))}});module.exports=c;