关于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)

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM