微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

得到“编译器无法在合理的时间内对该表达式进行类型检查;尝试将表达式分解为不同的子表达式”

如何解决得到“编译器无法在合理的时间内对该表达式进行类型检查;尝试将表达式分解为不同的子表达式”

目前我正在学习 SwiftUI,但我面临着一个问题。编译器无法对表达式进行类型检查。

当我添加 Text(update.date) 时,一切就开始了。此外,更新是我创建的结构,其中数据成员之一是字符串类型的日期。

代码长度有关系吗??

我已经添加错误代码和快照。

import SwiftUI

struct UpdateList: View {
    
    var body: some View {
        
        NavigationView {
            List(updateData) { update in
                NavigationLink(destination: Text(update.text)) {
                    vstack(alignment: .leading) {

                        Text(update.title)
                            .font(.system(size: 20,weight: .bold))

                        Text(update.text)
                            .font(.subheadline)
                            .lineLimit(2)
                            .foregroundColor(Color(#colorLiteral(red: 0.2549019754,green: 0.2745098174,blue: 0.3019607961,alpha: 1)))

                        Text(update.date)   //all the errors occurred when typed this
                            .forgroundColor(.secondary)

                    }
                }
            }
            .navigationBarTitle(Text("Updates"))
        }
        
    }
}

struct UpdateList_Previews: PreviewProvider {
    static var previews: some View {
        UpdateList()
    }
}

struct Update: Identifiable{
    var id = UUID()
    var image: String
    var title: String
    var text: String
    var date: String
}

let updateData: [Update] = [
    Update(image: "Card1",title: "SwiftUI Advanced",text: "Take your app to App Store with advanced techniques like API data,packages and CMS",date: "JAN 1"),Update(image: "Card2",title: "WebFlow",text: "Design and animate a high converting landing page with advanced interations,payments and CMS",date: "OCT 17"),Update(image: "Card3",title: "ProtoPie",text: "Quickly Prototype advanced animations nd interactions for mobile and Web",date: "AUG 27"),Update(image: "Card4",title: "SwiftUI",text: "Learn how to code custom UI,animations and gestures and components in Xcode 11",date: "JUNE 26"),Update(image: "Card5",title: "Framer Playground",text: "Create powerful animations and interactions with Framer X code editor",date: "JUNE 11")
]

有什么建议吗??

这是快照:https://i.stack.imgur.com/LXOrH.png

提前致谢

解决方法

.forgroundColor(.secondary)

应该

.foregroundColor(.secondary)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。