切换语言为:繁体
xcode报错Initializer ‘init(_:)‘ requires that ‘Binding<String>‘ conform to ‘StringProtocol‘

xcode报错Initializer ‘init(_:)‘ requires that ‘Binding<String>‘ conform to ‘StringProtocol‘

  • 爱糖宝
  • 2024-07-01
  • 2074
  • 0
  • 0

在使用list展示数据的时候,出错了:

Cannot assign to property: 'icon' is a 'let' constant

Initializer 'init(_:)' requires that 'Binding<String>' conform to 'StringProtocol'

这是因为前面使用的$foods是Bind类型,所以后面的food也要是Bind类型,所以就报错了。

解决办法:

使用$food进行渲染,就不会报错了

xcode报错Initializer ‘init(_:)‘ requires that ‘Binding<String>‘ conform to ‘StringProtocol‘

渲染出来的画面也正常了:

xcode报错Initializer ‘init(_:)‘ requires that ‘Binding<String>‘ conform to ‘StringProtocol‘

0条评论

您的电子邮件等信息不会被公开,以下所有项均必填

OK! You can skip this field.