Skip to content

feat: Add virtual list component#739

Open
alice52hz wants to merge 2 commits intoksc-fe:masterfrom
alice52hz:virtualList
Open

feat: Add virtual list component#739
alice52hz wants to merge 2 commits intoksc-fe:masterfrom
alice52hz:virtualList

Conversation

@alice52hz
Copy link
Copy Markdown
Collaborator

Add new component: virtualList

Copy link
Copy Markdown
Member

@Javey Javey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外还可以考虑hooks拆分逻辑

nativeProps?: any
start: number
end: number
enableVirtualList?: boolean | string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议改为disable属性名,跟其他组件的设计保持一致,不过你这里可以为string,另外string还可以具体到auto字符串

Comment thread components/virtualList/index.ts Outdated
static typeDefs = typeDefs;
static defaults = defaults;
static template = function(this: Virtual) {
const vt = this;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用保存this,凡是使用this的地方,都可以用箭头函数

Comment thread components/virtualList/index.ts Outdated

const outerAttrs = {
...nativeProps,
'ev-scroll': function(this: HTMLDivElement) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数建议提出来,另外如果要访问dom,可以通过事件对象Event访问,这里可以改为箭头函数。不过还是建议放到Component原型链上,使用@bind装饰器,否则这里会重复定义函数

};

init() {
if(!this.get('enableVirtualList')) return;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有没有考虑这个属性,可能会动态改变的情况

Comment thread components/virtualList/index.ts Outdated
this.range.start = start;
this.range.end = end;
this.range.paddingTop = this.getPadFront();
this.range.paddingBottom = this.getPadBehind();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

像这样要多次取值,可以保存临时变量const range = this.range,有微小的性能提升

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants