Vue: TodoMVC的demo里有一个逻辑错误

Created on 27 Apr 2017  ·  5Comments  ·  Source: vuejs/vue

Version

2.3.0

Reproduction link

https://jsfiddle.net/yyx990803/4dr2fLb7/?utm_source=website&utm_medium=embed&utm_campaign=4dr2fLb7

Steps to reproduce

js代码的135行:

if (value) {

这里的value从文档上看应该是一个binding对象,如果这样判断,这个if的值永远为true,因此这个if毫无意义。

按照上下文逻辑,这里应该是if(value.value)才对或者直接是:

'todo-focus': function (el, binding) {
    if (binding.value) {
        el.focus()
    }
}

如果我理解没错,希望作者改进一下,看到这里的时候很容易产生误导。
如果我理解错了,希望理解,才接触vue不久,谢谢!

What is expected?

if(Boolean)

What is actually happening?

if(Object)

Most helpful comment

Nice catch 🙂
I notified Evan since he's the one that can edit that fiddle. It should be fixed soon

All 5 comments

🐮 👃

🐮 👃

Nice catch 🙂
I notified Evan since he's the one that can edit that fiddle. It should be fixed soon

@posva Thanks very much!

Fixed, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loki0609 picture loki0609  ·  3Comments

franciscolourenco picture franciscolourenco  ·  3Comments

fergaldoyle picture fergaldoyle  ·  3Comments

paceband picture paceband  ·  3Comments

bfis picture bfis  ·  3Comments