小程序对多个三目运算支持性不好
发布于 6 年前 作者 azhang 7867 次浏览 来自 问答

var attaches=[1,2,3]  attaches.length==1?‘oneImgs’:attaches.length==4?‘fourImgs’:‘otherImgs’    结果并不是’otherImgs’

最后找到解决办法,在后边的三目运算加上括号才可以:attaches.length==1?‘oneImgs’:(attaches.length==4?‘fourImgs’:‘otherImgs’)

回到顶部