swiftui“没有参数”使用网站链接时错误
我正在开发一个简单的联系人应用程序,当添加下面显示的行时,我会收到错误:传递给呼叫的参数,该呼叫没有参数。
let websitetext: String
init(){
self.websitetext = contact.website
}
以下是删除无关数据的整个文件。
import Foundation
import SwiftUI
struct ContactsDetailView: View{
let contact: Contact
let websitetext: String //lines referenced
init(){
self.websitetext = contact.website
}
var body: some View {
HStack{
VStack {
Image(contact.imageName)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 100, height: 100)
.clipped()
.cornerRadius(50)
Text(contact.name)
.font(.system(size: 21, weight:.medium, design: .default))
Form{
HStack {
Text ("Phone")
Spacer()
Text(contact.phone)
.foregroundColor(.gray)
.font(.callout)
}
Section{
Link("Website", destination: URL(string: websitetext)!) //Uses the website text variable
}
}
}
}
}
}
struct ResourcesDetailView_Previews: PreviewProvider {
static var previews: some View {
ContactsDetailView(contact: contacts[0]) //ERROR LINE
}
}
解决此问题的任何帮助将不胜感激!
I'm developing a simple contacts application, when adding the lines shown below, I receive the error: Argument passed to call that takes no arguments.
let websitetext: String
init(){
self.websitetext = contact.website
}
Below is the entire file with irrelevant data removed.
import Foundation
import SwiftUI
struct ContactsDetailView: View{
let contact: Contact
let websitetext: String //lines referenced
init(){
self.websitetext = contact.website
}
var body: some View {
HStack{
VStack {
Image(contact.imageName)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 100, height: 100)
.clipped()
.cornerRadius(50)
Text(contact.name)
.font(.system(size: 21, weight:.medium, design: .default))
Form{
HStack {
Text ("Phone")
Spacer()
Text(contact.phone)
.foregroundColor(.gray)
.font(.callout)
}
Section{
Link("Website", destination: URL(string: websitetext)!) //Uses the website text variable
}
}
}
}
}
}
struct ResourcesDetailView_Previews: PreviewProvider {
static var previews: some View {
ContactsDetailView(contact: contacts[0]) //ERROR LINE
}
}
Any help to solve this issue would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论