Kaynağa Gözat

提交调整获取屏幕宽度

wenmenghao 10 ay önce
ebeveyn
işleme
a4cc066f41

+ 2 - 1
jydocs-pc/src/components/SelectedRecommend.vue

@@ -75,7 +75,7 @@ export default {
       this.$emit('click', item)
     },
     setItemwidth () { // 适配嵌入工作台内
-      const bodyWidth = document.body.clientWidth
+      const bodyWidth = window.screen.width - 212
       if (window.goTemplateData && window.goTemplateData.inIframe && bodyWidth > 1248) {
         const element = document.querySelectorAll('.card-item')[0]
         const itemwidth = element.offsetWidth + 104 // 104是margin
@@ -84,6 +84,7 @@ export default {
         var elements = document.querySelectorAll('.card-item')
         elements.forEach(function (ele) {
           ele.style.width = newwidth + 'px' // 设置新的宽度
+          console.log(ele.style.width)
         })
       }
     }