Comments (3)
从下往上的删除dom是没问题的,先把第3个商品减到0,再减2/1,这么做都没问题。
所有的dom都在,没有删除任何一个dom的时候也没问题。加减都是操作的对应的dom。
只有从上往下删除的时候是有问题的。。
from simple-virtual-dom.
@occultskyrong 我调试啦一天,我觉得应该是 jquery的问题,jquery应该把元素的属性缓存下来处理,然后当第一个被删除了,因为diff算法会把第一个点变成第二个点,自身的属性改变了,但是jquery的包装属性没变,这是坑得注意。
可以这么改:
var changeQuantity = function (e, qua) {
var gid = e.parentNode.dataset.gid
, good = GOODS[gid];
good.quantity = parseInt(good.quantity) + qua;
Calc.reset();
container();
};
注意这里传的是dom对象后面的加减不要用$包装,还有,如果你用过react,你这个代码并不是最佳实践。
还有你是不是知呼上那个匿名回答的那个人。
from simple-virtual-dom.
@maiff
先谢谢,稍候我会试一下。
没用过react,整站基本上都是webpack去打包匿名+闭包来封装模块实现的。
主要是以前纯jQuery+ 自封装方法需要写的东西太多,尤其是监听这一块,dom的操作本身就慢,写个listener更麻烦。。
所以打算找个轮子改一下。
如果虚拟dom可以分拆一个组件的化,可能会直接封装进去,然后直接用这一个组件完成整个页面的构造。
当然,肯定会考虑上react。。
现在也在尝试。
from simple-virtual-dom.
Related Issues (20)
- 请问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
- 点击排序有问题
- list-diff2是个什么东东? HOT 1
- 文档补全
- 用push的方法往一个已创建的Element里插入childern,不能自动更新Element的count HOT 7
- 两颗树的最小距离 HOT 3
- difference between developit/preact ? HOT 1
- Improve compatibility with JSX HOT 4
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.