let sometext: LocalizedStringKey = "sometext"
var body: some View {
Text(sometext + " some more text") // Error: Binary operator '+' cannot be applied to operands of type 'LocalizedStringKey' and 'String'
}
为什么这不起作用,我该如何解决?
我也发现了这一点,但是作为初学者,我并不真正理解答案 https://www.reddit.com/r/swift/comments/d50afb/localizedstringkey_to_string/
答案 0 :(得分:2)
这是在swiftUI中一起添加文本的方式。
var body: some View {
Text(sometext) + Text("some more text")
}