关于VUE的v-if失效的一种可能

页面上v-if一直不起作用, 直到我打印结果时....

            let item=data.page.list[1]
            console.info(item.zstp && item.zstp.length>5)
            console.info(item.zstp && item.zstp.length>5)
            console.info(item.zstp && item.zstp.length>5)

打印的结果:

由于js的 逻辑运算符不返回逻辑值而导致的错误.

console.info(!!item.zstp && item.zstp.length>5)

这种强转就能正常返回逻辑值

原文地址:https://www.cnblogs.com/ztw1122/p/14903723.html