Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

vue 中 ,如何优化v-for循环的,控制元素显示隐藏语句?

情景:
数据列表中v-for 循环的 , 一些元素的显示隐藏依赖于数组中的字段 ,切判断的条件比较多,看着页面就不清爽 ,请问这些数据怎么处理,可以优化下呢?

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

1.template 标签中,用 slot-scope={row},可以代替 scope.row
2.后面三个按钮的判断条件,可以用一个逻辑来代替:

v-else-if="state >= 50 && (row.type == 1 || (row.type == 2 && hasJudicial == 1) || (row.type !== 2 && row.type !== 1 && row.hasChain))"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...