App.vue 545 B

1234567891011121314151617181920212223242526
  1. <script setup lang="ts">
  2. import { onMounted } from 'vue';
  3. const setFontSize = () => {
  4. // 字体大小动态调整
  5. const width = document.body.clientWidth;
  6. const fontSize = width / 137;
  7. const html = document.getElementsByTagName('html')[0];
  8. html.style.fontSize = fontSize + 'px';
  9. };
  10. onMounted(() => {
  11. setFontSize();
  12. window.onresize = () => {
  13. setFontSize();
  14. };
  15. });
  16. </script>
  17. <template>
  18. <router-view></router-view>
  19. </template>
  20. <style>
  21. @import './assets/css/main.scss';
  22. </style>
  23. <style scoped></style>