{"id":316,"date":"2021-10-24T19:56:25","date_gmt":"2021-10-24T11:56:25","guid":{"rendered":"http:\/\/gjweb.top\/?p=316"},"modified":"2021-10-24T19:56:26","modified_gmt":"2021-10-24T11:56:26","slug":"%e9%95%bf%e5%88%97%e8%a1%a8%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=316","title":{"rendered":"\u957f\u5217\u8868\u6027\u80fd\u4f18\u5316"},"content":{"rendered":"\n<ul class=\"wp-block-list\"><li>\u573a\u666f\uff1a\u5c55\u793a<strong>\u5927\u578b\u5217\u8868\u548c\u8868\u683c\u6570\u636e<\/strong>\uff08\u6bd4\u5982\uff1a\u57ce\u5e02\u5217\u8868\u3001\u901a\u8baf\u5f55\u3001\u5fae\u535a\u7b49\uff09\uff0c<strong>\u4f1a\u5bfc\u81f4\u9875\u9762\u5361\u987f<\/strong>\uff0c\u6eda\u52a8\u4e0d\u6d41\u7545\u7b49\u6027\u80fd\u95ee\u9898<\/li><li>\u539f\u56e0\uff1a\u5927\u91cfDOM\u8282\u70b9\u7684<strong>\u91cd\u7ed8<\/strong>\u548c<strong>\u91cd\u6392<\/strong><\/li><li>\u5176\u4ed6\u95ee\u9898\uff1a\u8bbe\u5907\u8001\u65e7\u3001\u79fb\u52a8\u8bbe\u5907<strong>\u8017\u7535\u91cf\u52a0\u5feb<\/strong>\u3001\u5f71\u54cd\u7535\u6c60<strong>\u4f7f\u7528\u5bff\u547d<\/strong><\/li><li>\u4f18\u5316\u65b9\u6848\uff1a1.\u61d2\u52a0\u8f7d 2. \u53ef\u89c6\u533a\u6e32\u67d3\uff08\u865a\u62df\u5217\u8868\uff09<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u61d2\u52a0\u8f7d<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5e38\u89c1\u7684\u957f\u5217\u8868\u4f18\u5316\u65b9\u6848\uff0c\u5e38\u89c1\u4e8e<strong>\u79fb\u52a8\u7aef<\/strong><\/li><li>\u539f\u7406\uff1a\u6bcf\u6b21\u4e4b\u6e32\u67d3\u4e00\u90e8\u5206\uff08\u6bd4\u598210\u6761\u6570\u636e\uff09\uff0c\u7b49\u6e32\u67d3\u7684\u6570\u636e\u5373\u5c06\u6eda\u52a8\u5b8c\u65f6\uff0c\u5728\u6e32\u67d3\u4e0b\u9762\u90e8\u5206<\/li><li>\u4f18\u5316\uff1a\u6bcf\u6b21\u6e32\u67d3\u4e00\u90e8\u5206\u6570\u636e\uff0c\u901f\u5ea6\u5feb<\/li><li>\u7f3a\u70b9\uff1a<strong>\u6570\u636e\u91cf\u5927\u65f6<\/strong>\uff0c\u9875\u9762\u4e2d\u4f9d\u7136<strong>\u5b58\u5728*<\/strong>*\u5927\u91cfDOM\u8282\u70b9<strong>\uff0c<\/strong>\u5360\u7528\u5185\u5b58\u8fc7\u591a**\uff0c\u964d\u4f4e\u6d4f\u89c8\u5668\u6e32\u67d3\u6027\u80fd\uff0c\u5bfc\u81f4\u9875\u9762\u5361\u987f<\/li><li>\u4f7f\u7528\u573a\u666f\uff1a\u6570\u636e\u91cf\u4e0d\u5927\u7684\u60c5\u51b5<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u53ef\u89c6\u533a\u6e32\u67d3<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u539f\u7406\uff1a\u4e4b\u6e32\u67d3\u9875\u9762\u53ef\u89c6\u533a\u57df\u7684\u5217\u8868\u9879\uff0c\u5728\u6eda\u52a8\u5217\u8868\u65f6\u52a8\u6001\u66f4\u65b0\u5217\u8868\u9879<\/li><li>\u4f7f\u7528\u573a\u666f\uff1a<strong>\u4e00\u6b21\u6027\u5c55\u793a\u5927\u91cf\u6570\u636e\u7684\u60c5\u51b5<\/strong><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728react\u4e2d\u7684\u5e94\u7528<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f7f\u7528 react-virtualized<\/h3>\n\n\n\n<p><a href=\"https:\/\/github.com\/sadrun\/react-virtualized\">\u8df3\u8f6c\u6587\u6863<\/a><\/p>\n\n\n\n<p>install<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install react-virtualized --save<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import React from \"react\";<br>import { List, AutoSizer } from \"react-virtualized\"<br>class CityList extends React.Component {<br> &nbsp; &nbsp;constructor(props){<br> &nbsp; &nbsp; &nbsp; &nbsp;super(props)<br> &nbsp; &nbsp; &nbsp; &nbsp;this.state = {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;list:&#91;111]<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;rowRenderer=({<br> &nbsp; &nbsp; &nbsp; &nbsp;key, <br> &nbsp; &nbsp; &nbsp; &nbsp;index,<br> &nbsp; &nbsp; &nbsp; &nbsp;isScrolling, <br> &nbsp; &nbsp; &nbsp; &nbsp;isVisible, <br> &nbsp; &nbsp; &nbsp; &nbsp;style,<br> &nbsp;  })=&gt;{<br> &nbsp; &nbsp;const {CityListFirst,CityList} = this.state;<br> &nbsp; &nbsp;const letter = CityListFirst&#91;index]<br> &nbsp; &nbsp;return (<br> &nbsp; &nbsp; &nbsp;&lt;div key={key} style={style} className=\"city\"&gt;<br> &nbsp; &nbsp; &nbsp;  {this.state.list&#91;index]}<br> &nbsp; &nbsp; &nbsp;&lt;\/div&gt;<br> &nbsp;  );<br>  }<br>}<br>\u200b<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728 vue \u4e2d\u7684\u5e94\u7528<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f7f\u7528 <a href=\"https:\/\/codechina.csdn.net\/mirrors\/Akryum\/vue-virtual-scroller\">vue-virtual-scroller<\/a><\/h3>\n\n\n\n<p>install<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install --save vue-virtual-scroller<\/code><\/pre>\n\n\n\n<p>import<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import VueVirtualScroller from 'vue-virtual-scroller';<br>import 'vue-virtual-scroller\/dist\/vue-virtual-scroller.css'<br>Vue.use(VueVirtualScroller)<br>\/\/ \u6309\u9700\u5f15\u5165<br>import { RecycleScroller } from 'vue-virtual-scroller'<br>import 'vue-virtual-scroller\/dist\/vue-virtual-scroller.css'<br>Vue.component('RecycleScroller', RecycleScroller)<\/code><\/pre>\n\n\n\n<p>\u793a\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;<br> &nbsp;&lt;RecycleScroller<br> &nbsp; &nbsp;class=\"scroller\"<br> &nbsp; &nbsp;:items=\"list\"<br> &nbsp; &nbsp;:item-size=\"32\"<br> &nbsp; &nbsp;key-field=\"id\"<br> &nbsp; &nbsp;v-slot=\"{ item }\"<br> &nbsp;&gt;<br> &nbsp; &nbsp;&lt;div class=\"user\"&gt;<br> &nbsp; &nbsp; &nbsp;{{ item.name }}<br> &nbsp; &nbsp;&lt;\/div&gt;<br> &nbsp;&lt;\/RecycleScroller&gt;<br>&lt;\/template&gt;<br>\u200b<br>&lt;script&gt;<br>export default {<br> &nbsp;props: {<br> &nbsp; &nbsp;list: Array,<br>  },<br>}<br>&lt;\/script&gt;<br>\u200b<br>&lt;style scoped&gt;<br>.scroller {<br> &nbsp;height: 100%;<br>}<br>\u200b<br>.user {<br> &nbsp;height: 32%;<br> &nbsp;padding: 0 12px;<br> &nbsp;display: flex;<br> &nbsp;align-items: center;<br>}<br>&lt;\/style&gt;<br>\u200b<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u573a\u666f\uff1a\u5c55\u793a\u5927\u578b\u5217\u8868\u548c\u8868\u683c\u6570\u636e\uff08\u6bd4\u5982\uff1a\u57ce\u5e02\u5217\u8868\u3001\u901a\u8baf\u5f55\u3001\u5fae\u535a\u7b49\uff09\uff0c\u4f1a\u5bfc\u81f4\u9875\u9762\u5361\u987f\uff0c\u6eda\u52a8\u4e0d\u6d41\u7545\u7b49\u6027\u80fd\u95ee\u9898 \u539f\u56e0\uff1a\u5927 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-316","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=316"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/316\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}