提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
提示:这里可以添加本文要记录的大概内容:
创建一个删除按钮,当点击删除按钮时,实现城市列表的删除(读者可以根据需要实现删除的内容),并出现一个弹框
提示:以下是本篇文章正文内容,下面案例可供参考
一、代码实现
Button("删除")
.fontSize(25)
.fontColor(Color.Gray)
.opacity(0.7)
.backgroundColor("#87CEEB")
.margin({ bottom: 15 })
.onClick(() => {
AlertDialog.show({ title: "删除",
message: `你确定要删除${this.cityNameList[this.cityIndex]}消息吗?`,
confirm: {
value: "确定",
action: () => {
this.cityNameList = this.cityNameList.filter(item => item !== this.cityNameList[this.cityIndex])
this.cityCodeList = this.cityCodeList.filter(item => item !== this.cityCodeList[this.cityIndex])
this.cityWeatherList = this.cityWeatherList.filter(item => item !== this.cityWeatherList[this.cityIndex])
}
}
})
})