📅  最后修改于: 2022-03-11 15:00:59.629000             🧑  作者: Mango
import SwiftUI
import Combine
final class SliderData: BindableObject {
let didChange = PassthroughSubject()
var sliderValue: Float = 0 {
willSet {
print(newValue)
didChange.send(self)
}
}
}
struct ContentView : View {
@EnvironmentObject var sliderData: SliderData
var body: some View {
Slider(value: $sliderData.sliderValue)
}
}