wlx200510 / TypeScriptLearn

学习微软出品的typeScript的语法
11 stars 1 forks source link

代码 review #2

Open xcatliu opened 6 years ago

xcatliu commented 6 years ago

https://github.com/wlx200510/TypeScriptLearn/blob/e48ae0a37220d84bea407f6e1ce14a9506fe92eb/src/Todo.ts#L38-L42

这里也可以每次执行完 this.items[index].done = !this.items[index].done 之后,就执行 this.updateUlElement() 重新渲染所有内容,然后在渲染的时候,根据 done 的取值决定要不要 line-through。 也就是类似 react 等框架的思想,只是没有虚拟 dom 了。

其他部分不错 :+1:

wlx200510 commented 6 years ago

收到 多谢鹅厂大佬指点 我这里当时是想减少dom的重绘所以才写了点冗余判断 当时没想到updateUlElement是可以走dom diff的功效 现在懂啦

发自我的小米手机 在 xcatliu notifications@github.com,2018年5月30日 10:32写道:

https://github.com/wlx200510/TypeScriptLearn/blob/e48ae0a37220d84bea407f6e1ce14a9506fe92eb/src/Todo.ts#L38-L42

这里也可以每次执行完 this.items[index].done = !this.items[index].done 之后,就执行 this.updateUlElement() 重新渲染所有内容,然后在渲染的时候,根据 done 的取值决定要不要 line-through。 也就是类似 react 等框架的思想,只是没有虚拟 dom 了。

其他部分不错 👍

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/wlx200510/TypeScriptLearn/issues/2, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARtoukqd1CUpLhL4b1I1K5N_AVfh1l1rks5t3gSygaJpZM4USgKU.

xcatliu commented 6 years ago

嗯,这里是会有非常多的冗余重绘,如果加上一套根据 diff 渲染的话,就更好了。 主要是为了让例子更简单易懂,所以没有上 react 那一套,其实是想表达类似的思想的

wlx200510 commented 6 years ago

现在准备上leetcode上多刷几个题 算法基础补一下 争取达到鹅厂要求

xcatliu commented 6 years ago

@wlx200510 算法和数据结构是程序员的基础,需要夯实。 不过前端对算法要求一般不是很高,达到 LeetCode Medium 难度就够了