allBrands.js 833 Bytes
Component({
  properties: {
    data: {
      type: null,
    },
    onlyTextBrand: {//纯文本展示品牌 '0' 图文品牌  '1' 纯文字品牌
      type: String,
      value: '0'
    }
  },

  data: {
    textBrandKey:[],
    textBrandData:[]
  },
  ready: function () {
    //头条列表渲染不支持字典循环,故转换成数组 2018/12/7
    if (this.properties.onlyTextBrand == '1') {
      let textBrandKey = [];
      let textBrandData = [];
      for (const iterator of Object.keys(this.properties.data)) {
        textBrandData.push(this.properties.data[iterator]);
        textBrandKey.push(iterator);
      }
      this.setData({
        textBrandData,
        textBrandKey
      })
    }
  },
  methods: {
    brandItemTapped: function(event) {
      this.triggerEvent('brandItemTapped', event);
    }
  }
})