We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
当前计算属性的同步变化顺序是以计算属性的定义顺序来的,即:
this.defineComputedProperty('foo', ['x'], () => this.get('x') + 1); this.defineComputedProperty('bar', ['x'], () => this.get('x') - 1);
当x发生变化时,先计算foo,后计算bar
x
foo
bar
问题是当计算属性依赖另一个计算属性时,顺序不对就会导致问题,比如:
this.defineComputedProperty('bar', ['foo'], () => this.get('foo') - 2); this.defineComputedProperty('foo', ['x'], () => this.get('x') + 1);
因为定义顺序顺序问题,bar比foo先计算,那么这一次bar的值就是错的,以后也永远会是错的
与 #28 相结合,如果有重定义计算属性,如父类先定义了foo再定义了bar(此时顺序正确),子类又重定义了foo(导致顺序错误),这问题会是非常隐性并且难以排查的
现在的问题是:
事实上计算属性是一个很危险的事物,应该补一下文档说明下计算属性为什么危险,并不推荐广泛使用,以及从实践上指导应该怎么用
The text was updated successfully, but these errors were encountered:
修复计算属性顺序问题
b06267a
Fix #29
No branches or pull requests
当前计算属性的同步变化顺序是以计算属性的定义顺序来的,即:
当
x
发生变化时,先计算foo
,后计算bar
问题是当计算属性依赖另一个计算属性时,顺序不对就会导致问题,比如:
因为定义顺序顺序问题,
bar
比foo
先计算,那么这一次bar
的值就是错的,以后也永远会是错的与 #28 相结合,如果有重定义计算属性,如父类先定义了
foo
再定义了bar
(此时顺序正确),子类又重定义了foo
(导致顺序错误),这问题会是非常隐性并且难以排查的现在的问题是:
事实上计算属性是一个很危险的事物,应该补一下文档说明下计算属性为什么危险,并不推荐广泛使用,以及从实践上指导应该怎么用
The text was updated successfully, but these errors were encountered: