【发布时间】:2022-02-03 06:16:01
【问题描述】:
我是 Phoenix/Elixir 的新手,正在尝试制作一个小聊天应用程序。我遇到了一些困难,希望您能提供帮助。
这是我的代码
<%= f = form_for :chat, "#", id: "chat-form", phx_submit: :submit_message %>
<%= text_input f, :message, placeholder: "Enter Message" %>
</form>
这会引发以下错误
(Phoenix.LiveView.HTMLTokenizer.ParseError) lib/chat_web/live/room_live.html.heex:13:5: unmatched closing tag. Expected </div> for <div> at line 6, got: </form>
删除结束标签会出现以下错误
(CompileError) lib/chat_web/live/room_live.html.heex:11: undefined function form_for/3
请有人帮我找出为什么它不起作用
【问题讨论】:
-
如果您将聊天变更集分配给 LiveView,请使用 @chat 而不是 :chat