App.vue 705 B

123456789101112131415161718192021222324252627282930313233
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {};
  10. },
  11. mounted() {
  12. window.onresize = () => {
  13. return (() => {
  14. // 为了对应不同的应用场景,添加了两种触发方式(全局变量缓存、全局事件总线)
  15. this.$store.commit("changeWindowsSize", document.body.clientWidth, document.body.clientHeight);
  16. this.$bus.$emit("windowOnresize", {
  17. windowsWidth: document.body.clientWidth,
  18. widthsHeight: document.body.clientHeight
  19. });
  20. })();
  21. };
  22. }
  23. };
  24. </script>
  25. <style scoped>
  26. #app {
  27. border: 0px;
  28. margin: 0px;
  29. width: 100%;
  30. height: 100%;
  31. }
  32. </style>