Vueuv icon indicating copy to clipboard operation
Vueuv copied to clipboard

如果一个node同时有for和if会漏掉一个吧

Open asuishi opened this issue 7 years ago • 1 comments

// if/for懒编译(编译完其他指令后才编译)
if (lazyCompileExp) {
	this[lazyCompileDir + 'Handler'](node, scope, lazyCompileExp);
} else {
	this.compile(node, scope);
}

asuishi avatar Mar 22 '17 13:03 asuishi

抛开代码想想,if和for是不是应该有优先级之分?如何定义这个优先级? 如果是if优先于for,那就应该先判断if的值,然后再决定是否要做循环。 如果是for优先于if,那就应该先循环,再在循环里面决定是否要渲染这个节点。

我这里当时也想过这个问题,但是简单化处理了,是有些不妥。按照目前多数框架的设计,应该是for优先于if,也是for执行循环,if决定节点留存。你可以看看怎么改。

qieguo2016 avatar Apr 19 '17 16:04 qieguo2016