我在列表项中添加了一个按钮,当我单击该按钮时,navigationLink的clickEvent触发器也会触发。当我只想触发按钮的clickEvent时,该怎么办?以下是我的代码:
ForEach(self.cares,id:\.id){ care in
HStack{
if(care.markMode == "打卡"){
Button("今日未打卡"){
}
else{
Button("新增记录"){
self.care = care
self.showSheetNewMark.toggle()
}
}
NavigationLink(destination:CareDetailView(care: care)){
Text("\(care.nickname!)的\(care.subject!)")
}
}
}
为按钮添加PlainButtonStyle
,如下例所示>>
Button("新增记录"){
self.care = care
self.showSheetNewMark.toggle()
}
.buttonStyle(PlainButtonStyle()) // << here !!