Commit ba0f05a4 authored by chenqikuai's avatar chenqikuai

reactive

parent a1aa3d6d
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from "vue"; import { throttle } from "lodash";
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
const props = defineProps<{ const props = defineProps<{
elementWidth: number; elementWidth: number;
...@@ -71,6 +72,21 @@ onMounted(() => { ...@@ -71,6 +72,21 @@ onMounted(() => {
); );
}); });
const handleResize = () => {
widthOfContainer.value = containerRef.value?.clientWidth!;
maxNumInOneLine.value = getMaxNumInOneLine(
widthOfContainer.value!,
widthOfElement.value,
ELEMENT_MIN_GAP
);
};
window.onresize = throttle(handleResize, 100);
onBeforeUnmount(() => {
window.onresize = null;
});
function getMaxNumInOneLine( function getMaxNumInOneLine(
containerWidth: number, containerWidth: number,
elementWidth: number, elementWidth: number,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment