示例工程 40-windows-scenes-macos

40-windows-scenes-macos/Diagnostics/OpenWindowInt.swift

swift · 0.3 KB

// 故意编译失败:openWindow 的 id 是字符串,不是整数。
// 复现:swiftc -typecheck Diagnostics/OpenWindowInt.swift
import SwiftUI
 
struct Bad: View {
    @Environment(\.openWindow) private var openWindow
 
    var body: some View {
        Button("开") { openWindow(id: 1) }
    }
}