refactor: improve signature component resize handling
This commit is contained in:
parent
30695c234d
commit
6b6a7ada79
|
|
@ -57,7 +57,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted, computed, onUnmounted, watch } from "vue";
|
||||
import { ref, onMounted, computed, onUnmounted, watch, nextTick } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { Local } from "@/utils/storage.js";
|
||||
import { receiveCode } from "@/api/index.js";
|
||||
|
|
@ -126,6 +126,10 @@ function getSignatureHeight() {
|
|||
);
|
||||
if (content) {
|
||||
content.style.height = `${signatureHeight}px`;
|
||||
nextTick(() => {
|
||||
var _a;
|
||||
(_a = vanSignatureRef.value) == null ? void 0 : _a.resize();
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
|
|
@ -201,6 +205,10 @@ function updateGridSize() {
|
|||
size = Math.min(size, availableWidth);
|
||||
gridSize.value = size;
|
||||
}
|
||||
function handleResize() {
|
||||
updateGridSize();
|
||||
getSignatureHeight();
|
||||
}
|
||||
onMounted(() => {
|
||||
// 组件挂载后获取高度
|
||||
setTimeout(() => {
|
||||
|
|
@ -216,10 +224,10 @@ onMounted(() => {
|
|||
receiveName.value = marriageInfo.receiveName;
|
||||
}
|
||||
}
|
||||
window.addEventListener("resize", updateGridSize);
|
||||
window.addEventListener("resize", handleResize);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener("resize", updateGridSize);
|
||||
window.removeEventListener("resize", handleResize);
|
||||
});
|
||||
watch(nameChars, () => {
|
||||
updateGridSize();
|
||||
|
|
|
|||
Loading…
Reference in New Issue