{"id":33361,"date":"2024-11-25T10:29:04","date_gmt":"2024-11-25T02:29:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/33361\/"},"modified":"2024-11-25T10:29:04","modified_gmt":"2024-11-25T02:29:04","slug":"%e5%b0%8f%e7%a8%8b%e5%ba%8f%e4%b8%ad%e7%9a%84%e7%80%91%e5%b8%83%e6%b5%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/33361\/","title":{"rendered":"\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u7011\u5e03\u6d41"},"content":{"rendered":"<p>\u7011\u5e03\u6d41\u662f\u4e00\u79cd\u5f88\u5e38\u89c1\u7684\u7f51\u9875\u5e03\u5c40\uff0c\u89c6\u89c9\u8868\u73b0\u4e3a\u53c2\u5dee\u4e0d\u9f50\u7684\u591a\u680f\u5e03\u5c40\uff0c\u662f\u4e00\u79cd\u65f6\u4e0b\u5f88\u6d41\u884c\u7684\u5e03\u5c40\u5f62\u5f0f\uff0c\u6700\u8fd1\u5728\u5199\u5c0f\u7a0b\u5e8f\u6070\u597d\u4e5f\u78b0\u5230\u4e86\uff0c\u60f3\u4e86\u51e0\u79cd\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u6cd5\uff0c\u63a5\u4e0b\u6765\u5c31\u6765\u4e00\u8d77\u770b\u770b\u5177\u4f53\u7684\u5b9e\u73b0\u65b9\u6cd5\uff08\u6240\u7528\u7684\u65b9\u6cd5\u4e2d\u7528\u7684\u4f8b\u5b50\u90fd\u662f\u4e24\u680f\u7684\u5e03\u5c40\uff09\u3002<\/p>\n<h2>\u7b49\u9ad8\u7684\u7011\u5e03\u6d41<\/h2>\n<p>\u7b49\u9ad8\u7684\u7011\u5e03\u6d41\u987e\u540d\u601d\u4e49\u5c31\u662f\u7011\u5e03\u6d41\u91cc\u7684\u5355\u4e2a\u76d2\u5b50\u7684\u9ad8\u5ea6\u90fd\u662f\u4e00\u6837\u7684\uff0c\u8fd9\u79cd\u5f62\u5f0f\u7684\u7011\u5e03\u6d41\u5b9e\u73b0\u8d77\u6765\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u56e0\u4e3a\u4e0d\u6d89\u53ca\u5230\u76d2\u5b50\u9ad8\u5ea6\u7684\u8ba1\u7b97\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;view class=\"fall\"&gt;\n  &lt;view wx:for=\"{{list}}\" class=\"fall-item\"&gt;&lt;\/view&gt;\n&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>Page({\n  data: {\n    list: []\n  },\n  onLoad () {\n    let images = []\n    for (let i = 0; i &lt; 10; i++) {\n      images.push({\n        url: 'test'\n      })\n    }\n    this.setData({\n      list: images\n    })\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.fall {\n  display: flex;\n  flex-wrap: wrap;\n  background-color: #f7f7f7;\n}\n.fall-item {\n  width: 330rpx;\n  height: 330rpx;\n  margin-top: 30rpx;\n  margin-left: 30rpx;\n  background-color: aquamarine;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\uff0c\u4f8b\u5b50\u4e2d\u7684\u76d2\u5b50\u5185\u5bb9\u5e76\u6ca1\u6709\u4f7f\u7528\u56fe\u7247\uff0c\u800c\u662f\u4f7f\u7528\u4e86\u8272\u5757\u4ee3\u66ff\uff0c\u7b49\u9ad8\u7011\u5e03\u6d41\u7684\u5b9e\u73b0\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7flex\u5e03\u5c40\u5b9e\u73b0\uff0c\u5982\u4f8b\u5b50\u6240\u793a\uff0c\u76f4\u63a5\u7528flex\u5e03\u5c40\uff0c\u5141\u8bb8\u6362\u884c\uff0c\u8bbe\u7f6e\u597d\u7011\u5e03\u6d41\u91cc\u4e2d\u6bcf\u4e00\u4e2a\u76d2\u5b50\u7684\u5bbd\u9ad8\uff0c\u5c31\u80fd\u5b9e\u73b0\u7b80\u5355\u7684\u5b9e\u73b0\u4e24\u680f\u7011\u5e03\u6d41\u5e03\u5c40<\/p>\n<h2>\u4e0d\u7b49\u9ad8\u7011\u5e03\u6d41<\/h2>\n<p>\u4e0d\u7b49\u9ad8\u7011\u5e03\u6d41\u662f\u66f4\u4e3a\u5e38\u89c1\u7684\u5f62\u5f0f\uff0c\u4e0d\u7b49\u9ad8\u7011\u5e03\u6d41\u6d89\u53ca\u5230\u5217\u9ad8\u7684\u8ba1\u7b97\uff0c\u7531\u4e8e\u6bcf\u4e2a\u76d2\u5b50\u7684\u9ad8\u5ea6\u4e0d\u4e00\u6837\uff0c\u56e0\u6b64\u9700\u8981\u6bcf\u4e00\u5217\u7684\u5217\u9ad8\u90fd\u8981\u8bb0\u5f55\u3001\u6bd4\u8f83\uff0c\u5c06\u4e0b\u4e00\u4e2a\u76d2\u5b50\u63d2\u5165\u9ad8\u5ea6\u77ee\u7684\u4e00\u5217\uff0c\u63a5\u4e0b\u6765\u5c31\u6765\u770b\u770b\u4e0d\u7b49\u9ad8\u7011\u5e03\u6d41\u7684\u5b9e\u73b0\u65b9\u5f0f<\/p>\n<h3>\u5df2\u77e5\u76d2\u5b50\u9ad8\u5ea6<\/h3>\n<p>\u4e00\u822c\u7011\u5e03\u6d41\u91cc\u5c55\u793a\u7684\u90fd\u662f\u56fe\u7247\uff0c\u8fd9\u79cd\u60c5\u51b5\u6307\u7684\u662f\u670d\u52a1\u7aef\u4f1a\u8fd4\u7ed9\u524d\u7aef\u8981\u5c55\u793a\u7684\u56fe\u7247\u7684\u5bbd\u9ad8\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u76f8\u5bf9\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u56e0\u4e3a\u670d\u52a1\u7aef\u4f1a\u8fd4\u56de\u56fe\u7247\u7684\u5bbd\u9ad8\uff0c\u524d\u7aef\u53ea\u9700\u8981\u8ba1\u7b97\u4e00\u4e0b\u5217\u9ad8\uff0c\u5c06\u4e0b\u4e00\u5f20\u56fe\u7247\u63d2\u5165\u77ee\u7684\u90a3\u91cc\u4e00\u5217\u5c31\u53ef\u4ee5\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;view class=\"fall\"&gt;\n  &lt;view wx:for=\"{{list}}\" wx:for-index=\"idx\" wx:for-item=\"column\" class=\"fall-column\"&gt;\n    &lt;view class=\"fall-column-item\" wx:for=\"{{column}}\" wx:for-index=\"i\" wx:for-item=\"item\" style=\"height: {{item.showHeight}}rpx\"&gt;&lt;\/view&gt;\n  &lt;\/view&gt;\n&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.fall {\n  display: flex;\n  background-color: #f7f7f7;\n}\n\n.fall-column {\n  display: flex;\n  flex-direction: column;\n  margin-left: 30rpx;\n}\n\n.fall-column-item {\n  width: 330rpx;\n  margin-top: 30rpx;\n  background-color: aquamarine;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>Page({\n  data: {\n    images: [{\n      width: 360,\n      height: 540\n    }, {\n      width: 480,\n      height: 540\n    }, {\n      width: 540,\n      height: 720\n    }, {\n      width: 720,\n      height: 960\n    }, {\n      width: 540,\n      height: 960\n    }, {\n      width: 360,\n      height: 720\n    }, {\n      width: 360,\n      height: 960\n    }, {\n      width: 540,\n      height: 540\n    }, {\n      width: 540,\n      height: 1440\n    }, {\n      width: 960,\n      height: 1440\n    }],\n    heightArr: [],\n    list: [],\n    col: 2\n  },\n  onLoad () {\n    this.initData(2)\n  },\n  initData (col) {\n    let images = []\n    let scale = 2\n    \/\/ \u6a21\u62df\u56fe\u7247\u5bbd\u9ad8\n    for (let i = 0; i &lt; 10; i++) {\n      let image = this.data.images[Math.floor(Math.random() * 10)]\n      images.push(image)\n    }\n    for (let i in images) {\n      let height = 165 \/ images[i].width * images[i].height * scale\n      images[i].showHeight = height\n      \/\/ \u7b2c\u4e00\u884c\u7684\u4e24\u4e2a\u76d2\u5b50\n      if (i &lt; col) {\n        this.data.list.push([images[i]])\n        this.data.heightArr.push(height)\n      } else {\n        \/\/ \u9009\u51fa\u9ad8\u5ea6\u8f83\u77ee\u7684\u4e00\u5217\u7684\u7d22\u5f15\n        let minHeight = Math.min.apply(null, this.data.heightArr)\n        let minHeightIndex = this.data.heightArr.indexOf(minHeight)\n        this.data.list[minHeightIndex].push(images[i])\n        this.data.heightArr[minHeightIndex] += height\n      }\n    }\n    this.setData({\n      list: this.data.list\n    })\n  },\n  onReachBottom () {\n    this.initData(0)\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u4f8b\u4e2d\u4e3a\u4e86\u65b9\u4fbf\u4e5f\u662f\u7528\u8272\u5757\u6a21\u62df\u4e86\u56fe\u7247\uff0c\u5728js\u4e2d\u6a21\u62df\u4e8610\u5f20\u56fe\u7247\u7684\u5bbd\u9ad8\uff0c\u6bcf\u6b21\u4ece\u4e2d\u968f\u673a\u53d610\u5f20\u56fe\u7247\uff0c\u5b9a\u4e49\u4e86\u4e24\u5217\uff0c\u6bcf\u6b21\u8ba1\u7b97\u4e00\u4e0b\u6bcf\u5217\u7684\u9ad8\u5ea6\uff0c\u5c06\u56fe\u7247\u63d2\u5165\u77ee\u7684\u90a3\u4e00\u5217\uff0c\u7136\u540e\u5c06\u8bb0\u5f55\u7528\u9ad8\u5ea6\u6570\u7ec4\uff0c\u5c06\u56fe\u7247\u7684\u9ad8\u5ea6\u7d2f\u52a0\uff0c\u5b9e\u73b0\u8d77\u6765\u4e5f\u5f88\u7b80\u5355<\/p>\n<h3>\u672a\u77e5\u76d2\u5b50\u9ad8\u5ea6<\/h3>\n<p>\u672a\u77e5\u76d2\u5b50\u9ad8\u5ea6\u7684\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8981\u600e\u4e48\u505a\u5462\uff1f<\/p>\n<h4>wx.getImageInfo<\/h4>\n<p>\u7b2c\u4e00\u79cd\u529e\u6cd5\u5c31\u662f\u901a\u8fc7wx.getImageInfo\u53ef\u4ee5\u83b7\u53d6\u5230\u56fe\u7247\u5bbd\u9ad8\u4fe1\u606f\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;view class=\"fall\"&gt;\n  &lt;view class=\"fall-column\" wx:for=\"{{list}}\" wx:for-index=\"idx\" wx:for-item=\"column\" wx:key=\"{{idx}}\"&gt;\n    &lt;view class=\"fall-column-item\" wx:for=\"{{column}}\" wx:for-index=\"i\" wx:key=\"{{i}}\" wx:for-item=\"item\"&gt;\n      &lt;image class=\"fall-column-item-img\" src=\"{{item.cover}}\" mode=\"widthFix\"\/&gt;\n    &lt;\/view&gt;\n  &lt;\/view&gt;\n&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.fall {\n  display: flex;\n  background-color: #f7f7f7;\n}\n\n.fall-column {\n  display: flex;\n  flex-direction: column;\n  margin-left: 30rpx;\n}\n\n.fall-column-item {\n  margin-top: 30rpx;\n  line-height: 0;\n}\n\n.fall-column-item-img {\n  width: 330rpx;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>import api from '..\/..\/api\/index'\nPage({\n  data: {\n    list: [],\n    heightArr: []\n  },\n  async onLoad () {\n    let {results} = await api.fetchImages()\n    let col = 2\n    for (let i in results) {\n      results[i].cover = results[i].imageUrl\n      \/\/ \u83b7\u53d6\u56fe\u7247\u4fe1\u606f\n      let info = await this.loadImage(results[i].cover)\n      results[i].height = 165 \/ info.width * info.height\n      if (i &lt; col) {\n        this.data.list.push([results[i]])\n        this.data.heightArr.push(results[i].height)\n      } else {\n        let minHeight = Math.min.apply(null, this.data.heightArr)\n        let minHeightIndex = this.data.heightArr.indexOf(minHeight)\n        this.data.list[minHeightIndex].push(results[i])\n        this.data.heightArr[minHeightIndex] += results[i].height\n      }\n    }\n    this.setData({\n      list: this.data.list\n    })\n  },\n  loadImage (cover) {\n    return new Promise(resolve =&gt; {\n      wx.getImageInfo({\n        src: cover,\n        success: (res) =&gt; {\n          resolve(res)\n        }\n      })\n    })\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5f53\u670d\u52a1\u7aef\u6ca1\u6709\u8fd4\u56de\u56fe\u7247\u7684\u5bbd\u9ad8\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7wx.getImageInfo()\u83b7\u53d6\u5230\u56fe\u7247\u7684\u4fe1\u606f\uff0c\u8fd9\u91cc\u4e3a\u4e86\u4e0d\u6253\u4e71\u670d\u52a1\u8fd4\u56de\u65f6\u7684\u56fe\u7247\u987a\u5e8f\uff0c\u7279\u610f\u5c06\u8fd9\u4e2a\u5355\u72ec\u7528Promise\u5c01\u4e86\u4e00\u5c42\uff0c\u5c31\u662f\u4e3a\u4e86\u56fe\u7247\u52a0\u8f7d\u5b8c\u4e00\u5f20\u518d\u83b7\u53d6\u4e0b\u4e00\u5f20\uff0c\u4f46\u662f\u5f53\u56fe\u7247\u6bd4\u8f83\u5927\u7684\u65f6\u5019\u5c31\u4f1a\u5bfc\u81f4\u52a0\u8f7d\u7684\u65f6\u95f4\u4f1a\u5f88\u957f\uff0c\u4f1a\u6709\u957f\u65f6\u95f4\u7684\u767d\u5c4f\uff1a<br \/><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/image\/180\/588\/503\/1592535539359520.png\" class=\"aligncenter\" title=\"\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u7011\u5e03\u6d41\u63d2\u56fe\" alt=\"\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u7011\u5e03\u6d41\u63d2\u56fe\" \/><\/p>\n<p>\u8fd9\u662f\u56e0\u4e3awx.getImageInfo()\u83b7\u53d6\u56fe\u7247\u4fe1\u606f\u7684\u65f6\u5019\u4f1a\u5148\u5c06\u56fe\u7247\u4e0b\u8f7d\u4e0b\u6765\uff0c\u7136\u540e\u624d\u80fd\u83b7\u53d6\u56fe\u7247\u4fe1\u606f\uff0c\u8fd9\u5c31\u5bfc\u81f4\u65f6\u95f4\u4f1a\u6bd4\u8f83\u957f\uff0c\u4f46\u662f\u5982\u679c\u4e0d\u9700\u8981\u56fe\u7247\u52a0\u8f7d\u987a\u5e8f\u65f6\u53ef\u4ee5\u8003\u8651\u76f4\u63a5\u5e76\u884c\u52a0\u8f7d\uff0c\u4e0d\u7b49\u4e0a\u4e00\u5f20\u56fe\u7247\u52a0\u8f7d\u5b8c\u5c31\u52a0\u8f7d\u4e0b\u4e00\u5f20\uff0c\u8fd9\u6837\u5c31\u80fd\u66f4\u5feb\u7684\u5c55\u73b0<\/p>\n<h4>wx.getImageInfo\u4f18\u5316<\/h4>\n<p>\u65e2\u7136\u56fe\u7247\u52a0\u8f7d\u83b7\u53d6\u4fe1\u606f\u65f6\u95f4\u6bd4\u8f83\u957f\uff0c\u90a3\u8003\u8651\u662f\u5426\u53ef\u4ee5\u52a0\u4e0a\u4e00\u4e2a\u9ed8\u8ba4\u7684\u56fe\u7247\uff0c\u8fd9\u6837\u7528\u6237\u80fd\u5728\u7b2c\u4e00\u65f6\u95f4\u770b\u5230\u6709\u5185\u5bb9\u5c55\u793a\uff0c\u56fe\u7247\u4fe1\u606f\u62ff\u5230\u540e\u518d\u5c06\u56fe\u7247\u663e\u793a\u51fa\u6765\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;view class=\"fall\"&gt;\n  &lt;view class=\"fall-column\" wx:for=\"{{list}}\" wx:for-index=\"idx\" wx:for-item=\"column\" wx:key=\"{{idx}}\"&gt;\n    &lt;view class=\"fall-column-item\" wx:for=\"{{column}}\" wx:for-index=\"i\" wx:for-item=\"item\" wx:key=\"{{i}}\"&gt;\n      &lt;image class=\"fall-column-item-img\" src=\"{{item.cover}}\" mode=\"widthFix\"\/&gt;\n    &lt;\/view&gt;\n  &lt;\/view&gt;\n&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.fall {\n  display: flex;\n  background-color: #f7f7f7;\n}\n\n.fall-column {\n  display: flex;\n  flex-direction: column;\n  margin-left: 30rpx;\n}\n\n.fall-column-item {\n  position: relative;\n  margin-top: 30rpx;\n  line-height: 0;\n  background-color: #ccc;\n}\n\n.fall-column-item::after {\n  content: '\u52a0\u8f7d\u4e2d';\n  position: absolute;\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n  display: inline-block;\n  color: #666;\n}\n\n.fall-column-item-img {\n  position: relative;\n  width: 330rpx;\n  z-index: 1;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>import api from '..\/..\/api\/index'\nPage({\n  data: {\n    list: [],\n    heightArr: []\n  },\n  async onLoad () {\n    let {results} = await api.fetchImages()\n    let col = 2\n    for (let i = 0; i &lt; col; i++) {\n      this.data.list[i] = new Array(results.length \/ 2)\n    }\n    this.setData({\n      list: this.data.list\n    })\n    for (let i in results) {\n      results[i].cover = results[i].imageUrl\n      let info = await this.loadImage(results[i].cover)\n      results[i].height = 165 \/ info.width * info.height\n      if (i &lt; col) {\n        this.data.list[i][0] = results[i]\n        this.data.heightArr.push(results[i].height)\n      } else {\n        let minHeight = Math.min.apply(null, this.data.heightArr)\n        let minHeightIndex = this.data.heightArr.indexOf(minHeight)\n        let index = this.data.list[minHeightIndex].filter(Boolean).length\n        this.data.list[minHeightIndex][index] = results[i]\n        this.data.heightArr[minHeightIndex] += results[i].height\n      }\n    }\n    for (let i = 0; i &lt; col; i++) {\n      this.data.list[i] = this.data.list[i].filter(Boolean)\n    }\n    this.setData({\n      list: this.data.list\n    })\n  },\n  loadImage (cover) {\n    return new Promise(resolve =&gt; {\n      wx.getImageInfo({\n        src: cover,\n        success: (res) =&gt; {\n          resolve(res)\n        }\n      })\n    })\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u5c31\u5728\u56fe\u7247\u6ca1\u6709\u52a0\u8f7d\u5b8c\u4e4b\u524d\u7ed9\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u7684\u52a0\u8f7d\u4e2d\u7684\u663e\u793a\uff0c\u5f53\u7136\u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u53ea\u80fd\u63d0\u4f9b\u7b80\u5355\u7684\u4f18\u5316\u601d\u8def\uff0c\u5b9e\u9645\u4e2d\u7684\u52a0\u8f7d\u8fc7\u6e21\u52a8\u753b\u4e00\u5b9a\u4f1a\u8bbe\u8ba1\u5f97\u66f4\u7ec6\u817b<\/p>\n<h4>\u4e91\u5b58\u50a8\u83b7\u53d6\u7528\u6237\u4fe1\u606f<\/h4>\n<p>\u4e00\u822c\u5c0f\u7a0b\u5e8f\u4e2d\u7528\u5230\u7684\u56fe\u7247\u90fd\u662f\u5b58\u50a8\u5728\u4e91\u670d\u52a1\u5668\u4e0a\u7684\uff0c\u4e14\u4e91\u670d\u52a1\u5668\u4e00\u822c\u90fd\u4f1a\u63d0\u4f9b\u5728\u56fe\u7247\u8bf7\u6c42\u5730\u5740\u4e0a\u5e26\u53c2\u6570\u83b7\u53d6\u56fe\u7247\u4fe1\u606f\uff0c\u4ee5\u963f\u91cc\u4e91\u4e3a\u4f8b\uff0c\u53ef\u4ee5\u5728\u56fe\u7247\u94fe\u63a5\u4e0a\u62fc\u63a5?x-oss-process=image\/info\uff0c\u5c31\u80fd\u83b7\u53d6\u5230\u56fe\u7247\u4fe1\u606f\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;view class=\"fall\"&gt;\n  &lt;view class=\"fall-column\" wx:for=\"{{list}}\" wx:for-index=\"idx\" wx:for-item=\"column\" wx:key=\"{{idx}}\"&gt;\n    &lt;view class=\"fall-column-item\" wx:for=\"{{column}}\" wx:for-index=\"i\" wx:for-item=\"item\" wx:key=\"{{i}}\"&gt;\n      &lt;image class=\"fall-column-item-img\" src=\"{{item.cover}}\" mode=\"widthFix\"\/&gt;\n    &lt;\/view&gt;\n  &lt;\/view&gt;\n&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.fall {\n  display: flex;\n  background-color: #f7f7f7;\n}\n\n.fall-column {\n  display: flex;\n  flex-direction: column;\n  margin-left: 30rpx;\n}\n\n.fall-column-item {\n  position: relative;\n  margin-top: 30rpx;\n  line-height: 0;\n  background-color: #ccc;\n}\n\n.fall-column-item::after {\n  content: '\u52a0\u8f7d\u4e2d';\n  position: absolute;\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n  display: inline-block;\n  color: #666;\n}\n\n.fall-column-item-img {\n  position: relative;\n  width: 330rpx;\n  z-index: 1;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>let fetchPicInfo = async (url) =&gt; {\n  let [err, result] = await to(testFly.get(`${url}?x-oss-process=image\/info`))\n  if (err) throw err\n  return result.data\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>import api from '..\/..\/api\/index'\nPage({\n  data: {\n    list: [],\n    heightArr: []\n  },\n  async onLoad () {\n    let {results} = await api.fetchImages()\n    let col = 2\n    for (let i = 0; i &lt; col; i++) {\n      this.data.list[i] = new Array(results.length \/ 2)\n    }\n    this.setData({\n      list: this.data.list\n    })\n    for (let i in results) {\n      results[i].cover = results[i].imageUrl\n      let info = await api.fetchPicInfo(results[i].cover)\n      results[i].height = 165 \/ info.ImageWidth.value * info.ImageHeight.value\n      if (i &lt; col) {\n        this.data.list[i][0] = results[i]\n        this.data.heightArr.push(results[i].height)\n      } else {\n        let minHeight = Math.min.apply(null, this.data.heightArr)\n        let minHeightIndex = this.data.heightArr.indexOf(minHeight)\n        let index = this.data.list[minHeightIndex].filter(Boolean).length\n        this.data.list[minHeightIndex][index] = results[i]\n        this.data.heightArr[minHeightIndex] += results[i].height\n      }\n    }\n    for (let i = 0; i &lt; col; i++) {\n      this.data.list[i] = this.data.list[i].filter(Boolean)\n    }\n    this.setData({\n      list: this.data.list\n    })\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u5927\u5927\u51cf\u5c11\u56fe\u7247\u52a0\u8f7d\u7684\u65f6\u95f4\uff0c\u4e0d\u9700\u8981\u5c06\u56fe\u7247\u4e0b\u8f7d\u5230\u672c\u5730\u5728\u83b7\u53d6\u56fe\u7247\u4fe1\u606f\uff0c\u800c\u662f\u76f4\u63a5\u5411\u670d\u52a1\u5668\u8bf7\u6c42\u56fe\u7247\u4fe1\u606f\uff0c\u518d\u52a0\u4e0a\u6bcf\u6b21\u8bf7\u6c42\u53ea\u4f1a\u8fd4\u56de\u56fe\u7247\u57fa\u672c\u4fe1\u606f\u5c31\u51e0\u4e2a\u5b57\u6bb5\uff0c\u56e0\u6b64\u8bf7\u6c42\u65f6\u95f4\u4e5f\u975e\u5e38\u77ed\uff0c\u5982\u56fe\uff1a<br \/><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/image\/137\/787\/730\/1592535565112393.png\" class=\"aligncenter\" title=\"\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u7011\u5e03\u6d41\u63d2\u56fe1\" alt=\"\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u7011\u5e03\u6d41\u63d2\u56fe1\" \/><\/p>\n<p>\u8fd9\u6837\u7528\u6237\u80fd\u66f4\u5feb\u770b\u5230\u56fe\u7247\u663e\u793a\uff0c\u540c\u65f6\u4e5f\u52a0\u4e0a\u4e86\u56fe\u7247\u52a0\u8f7d\u65f6\u7684\u8fc7\u6e21\u6548\u679c\uff0c\u8fd9\u6837\u4f53\u9a8c\u6548\u679c\u4f1a\u66f4\u597d<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u628a\u6700\u8fd1\u5728\u5199\u5c0f\u7a0b\u5e8f\u65f6\u9047\u5230\u7684\u7011\u5e03\u6d41\u505a\u4e86\u4e00\u4e2a\u6bd4\u8f83\u8be6\u7ec6\u7684\u603b\u7ed3\uff0c\u4e0d\u540c\u7684\u60c5\u51b5\u4e0b\u9009\u62e9\u4e0d\u540c\u7684\u52a0\u8f7d\u65b9\u6848\uff0c\u4f53\u9a8c\u6548\u679c\u6700\u597d\u7684\u5f53\u7136\u8fd8\u662f\u670d\u52a1\u7aef\u76f4\u63a5\u8fd4\u56de\u56fe\u7247\u4fe1\u606f\uff0c\u8fd9\u6837\u80fd\u8282\u7701\u5f88\u591a\u83b7\u53d6\u56fe\u7247\u4fe1\u606f\u8981\u82b1\u7684\u65f6\u95f4\uff0c\u8fd9\u6837\u7528\u6237\u4f53\u9a8c\u66f4\u4f18\uff0c\u5e0c\u671b\u80fd\u5bf9\u5404\u4f4d\u5728\u5199\u5c0f\u7a0b\u5e8f\u7011\u5e03\u6d41\u80fd\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u5982\u679c\u6709\u9519\u8bef\u6216\u4e0d\u4e25\u8c28\u7684\u5730\u65b9\uff0c\u6b22\u8fce\u6279\u8bc4\u6307\u6b63\uff0c\u5982\u679c\u559c\u6b22\uff0c\u6b22\u8fce\u70b9\u8d5e<\/p>\n<p>\u63a8\u8350\u6559\u7a0b\uff1a\u300a\u300b<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5c0f\u7a0b\u5e8f\u4e2d\u7684\u7011\u5e03\u6d41\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7011\u5e03\u6d41\u662f\u4e00\u79cd\u5f88\u5e38\u89c1\u7684\u7f51\u9875\u5e03\u5c40\uff0c\u89c6\u89c9\u8868\u73b0\u4e3a\u53c2\u5dee\u4e0d\u9f50\u7684\u591a\u680f\u5e03\u5c40\uff0c\u662f\u4e00\u79cd\u65f6\u4e0b\u5f88\u6d41\u884c\u7684\u5e03\u5c40\u5f62\u5f0f\uff0c\u6700\u8fd1\u5728\u5199\u5c0f\u7a0b\u5e8f\u6070\u597d\u4e5f\u78b0\u5230\u4e86\uff0c\u60f3\u4e86\u51e0\u79cd\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u6cd5\uff0c\u63a5\u4e0b\u6765\u5c31\u6765\u4e00\u8d77\u770b\u770b\u5177\u4f53\u7684\u5b9e\u73b0\u65b9\u6cd5\uff08\u6240\u7528\u7684\u65b9\u6cd5\u4e2d\u7528\u7684\u4f8b\u5b50\u90fd\u662f\u4e24\u680f\u7684\u5e03\u5c40\uff09\u3002 \u7b49\u9ad8\u7684\u7011\u5e03\u6d41 \u7b49\u9ad8\u7684\u7011\u5e03\u6d41\u987e\u540d\u601d\u4e49\u5c31\u662f\u7011\u5e03\u6d41\u91cc\u7684\u5355\u4e2a\u76d2\u5b50\u7684\u9ad8\u5ea6\u90fd\u662f\u4e00\u6837\u7684\uff0c\u8fd9\u79cd\u5f62\u5f0f\u7684\u7011\u5e03\u6d41\u5b9e\u73b0\u8d77\u6765\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u56e0\u4e3a\u4e0d\u6d89\u53ca\u5230\u76d2\u5b50\u9ad8\u5ea6\u7684\u8ba1\u7b97\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a &lt;view class=&#8221;fall&#8221;&gt; &lt;view wx:for=&#8221;{{list}}&#8221; class=&#8221;fall-item&#8221;&gt;&lt;\/view&gt; &lt;\/view&gt; \u767b\u5f55\u540e\u590d\u5236 Page({ data: { list: [] }, onLoad () { let images = [] for (let i = 0; i &lt; 10; i++) { images.push({ url: &#8216;test&#8217; }) } this.setData({ list: images }) } }) \u767b\u5f55\u540e\u590d\u5236 .fall { display: flex; flex-wrap: wrap; background-color: #f7f7f7; } .fall-item [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-33361","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/33361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=33361"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/33361\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=33361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=33361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=33361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}