|
@@ -45,12 +45,18 @@ export default {
|
|
|
default: () => []
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ options (val) {
|
|
|
+ if (val.length > 0) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.setItemwidth()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
data () {
|
|
|
return {}
|
|
|
},
|
|
|
- mounted () {
|
|
|
- this.setItemwidth()
|
|
|
- },
|
|
|
methods: {
|
|
|
handleError (img) {
|
|
|
img.target.src = require('../assets/images/error.png')
|
|
@@ -71,10 +77,10 @@ export default {
|
|
|
setItemwidth () { // 适配嵌入工作台内
|
|
|
const bodyWidth = document.body.clientWidth
|
|
|
if (window.goTemplateData && window.goTemplateData.inIframe && bodyWidth > 1248) {
|
|
|
- const element = document.getElementsByClassName('card-item')[0]
|
|
|
+ const element = document.querySelectorAll('.card-item')[0]
|
|
|
const itemwidth = element.offsetWidth + 104 // 104是margin
|
|
|
- const num = Math.floor(bodyWidth / itemwidth)
|
|
|
- const newwidth = (Math.floor((bodyWidth - (itemwidth * num)) / num)) + itemwidth
|
|
|
+ const num = Math.floor((bodyWidth - 48) / itemwidth)
|
|
|
+ const newwidth = ((Math.floor((bodyWidth - (itemwidth * num) - 48) / num)) + itemwidth) - 104
|
|
|
var elements = document.querySelectorAll('.card-item')
|
|
|
elements.forEach(function (ele) {
|
|
|
ele.style.width = newwidth + 'px' // 设置新的宽度
|