Component({ properties: { object: { type: Object, value: null }, // 这里定义了innerText属性,属性值可以在组件使用时指定 }, data: { // 这里是一些组件内部数据 someData: {}, pic_height: 0,//图片组合的高度 is_yspan: 0, //是否要严格按照比例来实现 }, ready: function () { //-- console.log(this.data.object.data) -- //-- 计算图片组合占用的高度 -- var height = 0; var is_yspan = 0; this.properties.object.data.forEach(function (val, ind) { if (val.fir.x == 0) { height += val.y_span * 187; } if (val.y_span > 1) is_yspan = 1; }) this.setData({ pic_height: height, is_yspan: is_yspan }) }, methods: { //-- 智能跳转到页面 -- gopage(e) { var url = e.currentTarget.dataset.url; getApp().goto(url); }, previewImage(e){ let src =e.currentTarget.dataset.src; wx.previewImage({ current: src, // 当前显示图片的http链接 urls: [src] ,// 需要预览的图片http链接列表 }); } } })