【问题标题】:No exact matches in call to instance method 'appendInterpolation' in SwiftUI在 SwiftUI 中调用实例方法 \'appendInterpolation\' 没有完全匹配
【发布时间】:2022-09-28 21:44:55
【问题描述】:

我有这个问题,我不知道如何解决它。

Text(\"\\(Texts.orderCanceledText1) \\(syncViewModel._order.id) \\(Texts.orderCanceledText2)\") // ERROR : here
    struct Texts {
static let orderCanceledText1 : LocalizedStringKey = \"orderCanceledText1\"
    static let orderCanceledText2 : LocalizedStringKey = \"orderCanceledText2\"
    static let orderCanceledText3 : LocalizedStringKey = \"orderCanceledText3\"
}

我正在使用本地化,这就是我使用它的原因。

错误:\“调用实例方法没有完全匹配\'appendInterpolation\'\”

  • 如果上述任何变量包含 nil 或整数值,则使用 Texts.orderCanceledText1.description 同步 ViewModel.order.id.description Texts.orderCanceledText2.description
  • syncViewModel._order.id 的类型是什么?
  • @tromgy syncViewModel._order.id 工作正常,问题出在 Texts variables 上。是一个整数
  • @IrfanAnwar 那是我得到的错误 \" 类型 \'LocalizedStringKey\' 的值没有成员 \'description\' \"

标签: swift swiftui


【解决方案1】:

Irfan Anwar 给出了很好的链接。解决方案是: 让目标:LocalizedStringKey = “目标” 让文本 = 文本(目标)

然后 文本(目标).fontWeight(.bold)+文本(“(目标).fontWeight(.bold)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-09
    • 2021-12-14
    • 2020-09-16
    • 1970-01-01
    • 2021-03-14
    • 2022-11-19
    • 2023-03-18
    • 1970-01-01
    相关资源
    最近更新 更多