我用来在 NavigationView 中SwiftUI创建从行到详细视图(类似于教程https://developer.apple.com/tutorials/swiftui/building-lists-and-navigationNavigationLinks中所做的操作)。但是,当我在应用程序中进行测试时,NavgiationLink 在被点击后立即从详细视图导航回上一个视图(详细视图仅显示一秒钟)。
这是代码:
struct ItemsView: View {
var body: some View {
NavigationView {
VStack {
List {
ForEach(Query.items) { item in
NavigationLink(destination: ItemDetail(item: item)) {
ItemRow(item: item)
}
}
}
Spacer()
}
.navigationBarTitle(Text("Items"))
}
}
}
private struct ItemRow: View {
var item: Item
var body: some View {
VStack(alignment: .leading) {
Text(item.title)
.font(.headline)
item.completionDate.map({
Text("Created \($0.shortDateTime)")
})
item.completionDate.map({
Text("Active \(Date().offsetString(from: $0)) ago")
})
}
}
}
struct ItemDetail: View {
var …Run Code Online (Sandbox Code Playgroud) navigation realm swiftui ios-navigationview swiftui-navigationlink
我正在使用 Clojure 设置 lacinia-pedestal graphql 服务器,并尝试使用 apollo 使用客户端 javascript 代码访问它。但是,我无法访问本地主机上的 /graphql 端点,因为我试图从 COR 不允许的本地主机源 (localhost:3000) 访问它。如何使用 lacinia-pedestal 设置 COR?
这是服务器端代码(使用 lacinia 教程https://lacinia.readthedocs.io/en/latest/tutorial/component.html 进行设置)
(ns project.server
(:require [com.stuartsierra.component :as component]
[com.walmartlabs.lacinia.pedestal :as lp]
[io.pedestal.http :as http]))
(defrecord Server [schema-provider server]
component/Lifecycle
(start [this]
(assoc this :server (-> schema-provider
:schema
(lp/service-map {:graphiql true})
http/create-server
http/start)))
(stop [this]
(http/stop server)
(assoc this :server nil)))
(defn new-server
[]
{:server (-> {}
map->Server
(component/using [:schema-provider]))})
Run Code Online (Sandbox Code Playgroud)
客户端代码超级简单(使用 Apollo):
const client = new ApolloClient({
uri: …Run Code Online (Sandbox Code Playgroud)