From c28bbc9f7393ee12deb07a0f9830b069cc8a92cc Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Mon, 21 Mar 2022 16:09:10 +0800 Subject: [PATCH] fix: docs render error --- .../theme/global-components/CodeSimulator.vue | 23 ++++++++++++++++--- docs/.vuepress/theme/styles/index.styl | 4 ++++ docs/README.md | 8 +++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/docs/.vuepress/theme/global-components/CodeSimulator.vue b/docs/.vuepress/theme/global-components/CodeSimulator.vue index 4ff7638d6..c2f79ca3c 100644 --- a/docs/.vuepress/theme/global-components/CodeSimulator.vue +++ b/docs/.vuepress/theme/global-components/CodeSimulator.vue @@ -12,8 +12,20 @@ export default { activeIndex: 0 } }, - created(){}, + mounted(){ + this.onWindowResize() + window.addEventListener('resize', this.onWindowResize) + }, + beforeDestroy(){ + window.removeEventListener('resize', this.onWindowResize) + }, methods:{ + onWindowResize(){ + const contentWidth = getComputedStyle(document.querySelector('.theme-default-content')).width + if (window.matchMedia('(max-width: 410px)').matches) { + this.$refs.codeIframe.style.maxWidth = contentWidth + } + }, onClick(index){ this.activeIndex = index }, @@ -37,7 +49,7 @@ export default { h('iframe',{class:'code-iframe',attrs:{ src:this.src, frameborder:'0' - }}) + },ref:'codeIframe'}) ]), ] @@ -84,7 +96,7 @@ export default { } - diff --git a/docs/.vuepress/theme/styles/index.styl b/docs/.vuepress/theme/styles/index.styl index b3adb3447..b79e93030 100644 --- a/docs/.vuepress/theme/styles/index.styl +++ b/docs/.vuepress/theme/styles/index.styl @@ -88,6 +88,10 @@ main.page @media (max-width: $MQMobile) & margin-top $navbarHeight + img + max-width 100% !important + table + position relative h1, h2, h3, h4, h5, h6 diff --git a/docs/README.md b/docs/README.md index ae1503c78..9adfe41d3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -93,11 +93,15 @@ pageClass: custom-page-class 京东小程序版 -
+
+ +
-
+
+ +
-- GitLab