0

在实时视图中,我有这个片段:

  <div id="chat"><%= live_render(@socket, MyAppWeb.ChatLive.Index, id: "watch-chats", guest: @guest) %></div>

在 ChatLive.Index 我有这个挂载功能:


  @impl true
  def mount(%{"guest_id" => guest_id}, _session, socket) do
    ...
  end

  def mount(:not_mounted_at_router, session, socket) do
    mount(%{"guest_id" => socket.assigns.guest.id}, session, socket)
  end

但它给出了这个错误:

key :guest not found in: %{flash: %{}, live_action: nil}

mount(%{"guest_id" => socket.assigns.guest.id}, session, socket).

如何将诸如来宾之类的参数传递给live_render调用并在mount函数中提取它?

4

1 回答 1

0

如果您需要传递数据,则需要将其放入套接字的分配中。

于 2021-03-16T21:41:31.593 回答