feat: Add virtual list component#739
Open
alice52hz wants to merge 2 commits intoksc-fe:masterfrom
Open
Conversation
Javey
reviewed
Jul 15, 2022
| nativeProps?: any | ||
| start: number | ||
| end: number | ||
| enableVirtualList?: boolean | string |
Member
There was a problem hiding this comment.
建议改为disable属性名,跟其他组件的设计保持一致,不过你这里可以为string,另外string还可以具体到auto字符串
| static typeDefs = typeDefs; | ||
| static defaults = defaults; | ||
| static template = function(this: Virtual) { | ||
| const vt = this; |
|
|
||
| const outerAttrs = { | ||
| ...nativeProps, | ||
| 'ev-scroll': function(this: HTMLDivElement) { |
Member
There was a problem hiding this comment.
这个函数建议提出来,另外如果要访问dom,可以通过事件对象Event访问,这里可以改为箭头函数。不过还是建议放到Component原型链上,使用@bind装饰器,否则这里会重复定义函数
| }; | ||
|
|
||
| init() { | ||
| if(!this.get('enableVirtualList')) return; |
| this.range.start = start; | ||
| this.range.end = end; | ||
| this.range.paddingTop = this.getPadFront(); | ||
| this.range.paddingBottom = this.getPadBehind(); |
Member
There was a problem hiding this comment.
像这样要多次取值,可以保存临时变量const range = this.range,有微小的性能提升
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add new component: virtualList