简体   繁体   English

为什么 Phoenix LiveView 函数 `push_event` 未定义?

[英]Why is Phoenix LiveView Function `push_event` undefined?

I want to send an Event from liveView server to the Client, with this funtion:我想从 liveView 服务器向客户端发送一个事件,具有以下功能:

  def handle_event("test", _, socket) do
    {:noreply, push_event(socket, "testEvent", %{coins: 23, user: "user"})}
  end

This is explained very similar in the docs of liveview.这在 liveview 的文档中解释得非常相似。 https://hexdocs.pm/phoenix_live_view/js-interop.html But i get this error message: https://hexdocs.pm/phoenix_live_view/js-interop.html但我收到此错误消息:

(CompileError) undefined function push_event/3

Stacktrace:
  │ (elixir 1.10.4) src/elixir_locals.erl:114: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
  │ (stdlib 3.8) erl_eval.erl:680: :erl_eval.do_apply/6

have i missed some inmport?我错过了一些进口吗? or what I am doing wrong?或者我做错了什么?

I think the Problem was my version of live view.我认为问题是我的实时取景版本。 I had to upgrade:我不得不升级:

{:phoenix_live_view, "~> 0.13.0"},

to:到:

{:phoenix_live_view, "~> 0.14.4"},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM