小编HAH*_*SAH的帖子

TabView 选项卡更改时如何运行函数

我尝试了很多不同的方法,但没有一个有效,当我尝试添加 .onChange 时,我收到此错误

Instance method 'onChange(of:perform:)' requires that 'Binding<Int>' conform to 'Equatable'
Run Code Online (Sandbox Code Playgroud)

我这样定义 currentTab

@State var currentTab = 0;
Run Code Online (Sandbox Code Playgroud)

这段代码给出了错误

.onChange(of: $currentTab, perform: { newValue in
    print(newValue)
})
Run Code Online (Sandbox Code Playgroud)

swift swiftui

5
推荐指数
1
解决办法
1251
查看次数

标签 统计

swift ×1

swiftui ×1