1

我刚刚生成了一个新的实时视图应用程序,phx.new --live并且不断收到此错误:

[info] GET /orgs
[debug] Processing with Phoenix.LiveView.Plug.index/2
  Parameters: %{}
  Pipelines: [:browser]
[debug] QUERY OK source="orgs" db=3.6ms idle=1614.0ms
SELECT o0."id", o0."avatar_url", o0."description", o0."email_end", o0."name", o0."inserted_at", o0."updated_at" FROM "orgs" AS o0 []
[info] Sent 200 in 4ms
[info] CONNECTED TO Phoenix.LiveView.Socket in 215µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "...", "vsn" => "2.0.0"}
[error] an exception was raised:
    ** (FunctionClauseError) no function clause matching in Phoenix.LiveView.Channel.start_link/1
        (phoenix_live_view) lib/phoenix_live_view/channel.ex:12: Phoenix.LiveView.Channel.start_link({TopicalWeb.Endpoint, {#PID<0.3487.0>, #Reference<0.1633886798.3560439811.208106>}})
        (elixir) lib/dynamic_supervisor.ex:690: DynamicSupervisor.start_child/3
        (elixir) lib/dynamic_supervisor.ex:676: DynamicSupervisor.handle_start_child/2
        (stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
        (stdlib) gen_server.erl:690: :gen_server.handle_msg/6
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

复制信息

我用的是凤凰版1.5.3

然后我生成了一个“组织”模块mix phx.gen.live Orgs Org orgs name:string email_end:string avatar_url:string description:string

      scope "/orgs", TopicalWeb.OrgLive do
        live "/", Index, :index
        live "/new", Index, :new
        live "/:id/edit", Index, :edit

        live "/:id", Show, :show
        live "/:id/show/edit", Show, :edit
      end
4

1 回答 1

2

我发现我的 phoenix_live_view 版本太旧了:

-      {:phoenix_live_view, "~> 0.12.0"},
+      {:phoenix_live_view, "~> 0.13"},

注意:您可能想运行mix hex.search phoenix_live_view以找出最新版本:

Package                               Description                                            Version  URL                                                           
phoenix_live_view                     Rich, real-time user experiences with server-rende...  0.13.2   https://hex.pm/packages/phoenix_live_view                     
phoenix_view_assets                   Helps to manage view specific assets in phoenix pr...  0.1.4    https://hex.pm/packages/phoenix_view_assets                   
phx_custom_template                   An opinionated template to create phoenix apps, us...  0.1.3    https://hex.pm/packages/phx_custom_template   
于 2020-06-02T13:07:21.077 回答