Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数组simplediff为false,但数据引用变化时,会产生父子组件数据不一致 #245

Open
leeluolee opened this issue Feb 14, 2019 · 1 comment

Comments

@leeluolee
Copy link
Member

leeluolee commented Feb 14, 2019

数组simplediff为false,但数据引用变化时,会产生父子组件数据不一致

     const Component2 = Regular.extend({

         name: 'List',
         template: "<h1>{list1}</h1>",
         init() {

           setTimeout((function () {

             // 1. 实际也修改了parent.list对应的watcher里的last???
             this.data.list1[0] = 99
             // 2. 此时,Parent#list 值是 [] , 但是last变成了[99]。 深坑
             this.$update();
             expect(this.data.list1).to.eql([99]) // 实际是[]
             done()

           }).bind(this), 0);

         }
       });

       const Component = Regular.extend({

         name: 'Parent',

         template: `
                <List list1={list}/>
            `,
         config() {
           this.data.list = [];
           // this.data.list = [1]
         },
         init() {
           this.data.list = [];
           // this.data.list = [1] //同样会出错
           //  这个update 由于list并没有判断为改变,所以last还是原来的数组,此时List再修改就会导致出错
           this.$update();
         }
       });

       new Component().$inject('body');


     })
leeluolee added a commit that referenced this issue Feb 14, 2019
@leeluolee
Copy link
Member Author

0.6.3发

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

No branches or pull requests

1 participant