Comments (7)
@ibufu 一般情况下是不会直接操作Element的children的,Element应该在每次状态变更的时候重新构造。不知道你的问题具体是什么,能否提供一下具体代码呢?
from simple-virtual-dom.
@livoras 建好了一个Element后,需要做增删改,所以要往element的children里push,或者根据我设置的id遍历children修改数据。(因为只是很局部的操作)操作起来很麻烦,而且push的时候,还要更新count,不然diff的时候index就会出错。
from simple-virtual-dom.
@livoras 如果能开一个方便修改element的接口就好了
from simple-virtual-dom.
@ibufu 即使是非常小的局部修改,也应该重新构造整棵虚拟DOM。一个虚拟DOM树一旦构造就不应该手动修改,它只是保存目前DOM树的状态。状态变更就应该构造新的树,再和原来的树进行diff。否则diff出来的patches就不正确了。
from simple-virtual-dom.
@livoras 我明白你的意思,但是这样构建DOM树确实有点点麻烦。。如果能支持判断循环的方法就好了
from simple-virtual-dom.
@ibufu 把构造虚拟DOM的操作封装成函数,每次状态改变就去调用这个函数重新构造就好了:https://github.com/livoras/simple-virtual-dom/blob/master/example/increasing-items.html#L20
from simple-virtual-dom.
有后续类似问题可以重开此issue :-)
from simple-virtual-dom.
Related Issues (20)
- list-diff2是个什么东东? HOT 1
- 两颗树的最小距离 HOT 3
- difference between developit/preact ? HOT 1
- Improve compatibility with JSX HOT 4
- 删除dom后更新,listener出了个问题 HOT 3
- 请问diff文件里面的require('list-diff2')文件在哪?
- patch.js文件的一行代码疑惑 HOT 2
- Support for events?
- 好像字体图标会出现问题?
- 文本解析会有问题 HOT 1
- 关于文件依赖问题 HOT 1
- 直接操作dom多了会有bug
- swiper问题
- 打开sort-table.html排序问题 HOT 1
- 请问一下事件绑定问题
- diff算法里面,没考虑oldChildren为空,newChildren不为空的情况
- from github
- 点击排序有问题
- 文档补全
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-virtual-dom.