homeThree.js 825 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // components/blocks/home3/home3.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. items: {
  8. type: Array
  9. },
  10. specialData:{
  11. type: Object
  12. }
  13. },
  14. attached(){
  15. let has_margin = this.properties.specialData.has_margin;
  16. let sub_items_length = this.properties.specialData.items.length;
  17. let firstSubWidth = this.properties.specialData.items[0].width;
  18. if (has_margin){
  19. let scale = (1080 - (sub_items_length * firstSubWidth)) / (sub_items_length + 1);
  20. let padding = Math.ceil(((750 / 1080) * scale)) + 'rpx';
  21. this.setData({
  22. has_margin: has_margin,
  23. padding:padding
  24. });
  25. }
  26. },
  27. /**
  28. * 组件的初始数据
  29. */
  30. data: {
  31. has_margin:false,
  32. padding:''
  33. },
  34. /**
  35. * 组件的方法列表
  36. */
  37. methods: {
  38. }
  39. })