如果数组中的值为空,如何显示/隐藏按钮?

问题描述 投票:0回答:1
string vuejs3 show-hide
1个回答
0
投票

是的,通过使用

v-if
v-show

<button v-if="currentTrack.path_15 != null && currentTrack.path_15 != undefined && currentTrack.path_15 != ''" ... >15s</button>

你也可以为此创建一个计算属性:

computed: {
    isPath15Empty() {
       return this.currentTrack.path_15 == null || this.currentTrack.path_15 == undefined || this.currentTrack.path_15 == '';
    } 
}

然后

<button v-if="!isPath15Empty" ...
© www.soinside.com 2019 - 2024. All rights reserved.