Giter VIP home page Giter VIP logo

Comments (3)

occultskyrong avatar occultskyrong commented on June 22, 2024

从下往上的删除dom是没问题的,先把第3个商品减到0,再减2/1,这么做都没问题。

所有的dom都在,没有删除任何一个dom的时候也没问题。加减都是操作的对应的dom。

只有从上往下删除的时候是有问题的。。

from simple-virtual-dom.

maiff avatar maiff commented on June 22, 2024

@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.

occultskyrong avatar occultskyrong commented on June 22, 2024

@maiff
先谢谢,稍候我会试一下。

没用过react,整站基本上都是webpack去打包匿名+闭包来封装模块实现的。

主要是以前纯jQuery+ 自封装方法需要写的东西太多,尤其是监听这一块,dom的操作本身就慢,写个listener更麻烦。。

所以打算找个轮子改一下。
如果虚拟dom可以分拆一个组件的化,可能会直接封装进去,然后直接用这一个组件完成整个页面的构造。

当然,肯定会考虑上react。。
现在也在尝试。

from simple-virtual-dom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.