App.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div>
  3. <router-view></router-view>
  4. </div>
  5. </template>
  6. <script>
  7. import { ref, onMounted } from "vue"
  8. export default {
  9. name: 'App',
  10. setup() {
  11. onMounted(() => {
  12. document.title = 'SCD检测'
  13. // 创建一个 link 元素
  14. const link = document.createElement('link');
  15. link.rel = 'icon';
  16. link.type = 'image/x-icon';
  17. link.href = '../../assets/icon/Avatar.png'; // 替换为你的图标路径
  18. // 获取当前文档中原有的 link 元素
  19. const existingLink = document.querySelector('link[rel="icon"]');
  20. // 如果存在原有的 link 元素,则替换它;否则,将新创建的 link 元素添加到 head 中
  21. if (existingLink) {
  22. document.head.removeChild(existingLink);
  23. }
  24. document.head.appendChild(link);
  25. // 解决报错ResizeObserver loop completed with undelivered notifications.
  26. const debounce = (fn, delay) => {
  27. let timer = null;
  28. return function () {
  29. let context = this;
  30. let args = arguments;
  31. clearTimeout(timer);
  32. timer = setTimeout(function () {
  33. fn.apply(context, args);
  34. }, delay);
  35. }
  36. }
  37. const _ResizeObserver = window.ResizeObserver;
  38. window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  39. constructor(callback) {
  40. callback = debounce(callback, 16);
  41. super(callback);
  42. }
  43. }
  44. })
  45. },
  46. components: {
  47. }
  48. }
  49. </script>
  50. <style>
  51. body {
  52. margin: 0;
  53. background-color: #FFF;
  54. }
  55. </style>