Reactjs Elixir Pheonix通道(FunctionClauseError)在/3中的ProjectName.ModuleName.handle_中没有匹配的函数子句

Reactjs Elixir Pheonix通道(FunctionClauseError)在/3中的ProjectName.ModuleName.handle_中没有匹配的函数子句,reactjs,typescript,websocket,elixir,phoenix-framework,Reactjs,Typescript,Websocket,Elixir,Phoenix Framework,当通过Typescript连接到Elixir通道时,我遇到了这个错误 (FunctionClauseError)在/3ProjectName.ModuleName.handle\u中没有匹配的函数子句 为什么会发生错误 我怎样才能修好它 这是我的密码 typescriptchatView.tsx import React, { Component } from 'react' import { Socket} from 'phoenix' type MyProps = { }; type M

当通过Typescript连接到Elixir通道时,我遇到了这个错误

FunctionClauseError
)在/3ProjectName.ModuleName.handle\u中没有匹配的函数子句

  • 为什么会发生错误
  • 我怎样才能修好它
  • 这是我的密码

    typescript
    chatView.tsx

    import React, { Component } from 'react'
    import { Socket} from 'phoenix'
    
    type MyProps = {  };
    type MyState = { message: string  };
    
    export class Chat extends Component <MyProps, MyState> {
    
        static readonly sockets = new Socket("ws://127.0.0.1:4000/socket");
        static channel = Chat.sockets.channel("groups_forums:lobby", {})
    
        constructor(props: any) {
            super(props);
    
            Chat.sockets.connect()
    
            //bind
            this.handleChange = this.handleChange.bind(this);
            this.handleClick = this.handleClick.bind(this);
            this.handleLoad = this.handleLoad.bind(this);
            this.keyPress = this.keyPress.bind(this);
    
        }
    
    
        componentDidMount() {
            window.addEventListener('load', this.handleLoad);
        }
    
        handleLoad() {
            console.log("component loaded");
    
            Chat.channel.join()
                .receive("ok", (resp: any) => { console.log("Joined successfully", resp) })
                .receive("error", (resp: any) => { console.log("Unable to join", resp) })
                .receive("ignore", (resp: any) => {console.log("auth error", resp)})
    
            Chat.channel.onClose((close: any) => { console.log("closing bye  ", close) });
    
    
           Chat.channel.on("new:msg", msg => {
                scrollTo(0, document.body.scrollHeight)
              })
    
        }
    
    
        handleChange(e:any) {
            this.setState({ message: e.target.value });
       }
    
        keyPress(e:any){
            if (e.keyCode == 13) {
             Chat.channel.push("new:msg",{message: this.state.message},2000)   
            }
          }
    
        handleClick(e: any) {
            e.preventDefault();
           Chat.channel.push("new:msg", {message: this.state.message})
        }
    
    
        render() {
            return (
                <div style={{ position: "absolute", bottom: 0 }}>
                    <form>
                        <p className="form-group row">
                            <input style={{ marginLeft: 20, width: 200 }} defaultValue={''} onKeyPress={this.keyPress} onChange={ this.handleChange } id="message" type="text"></input>
    
                            <input style={{ marginLeft: 20, marginRight: 20 }} type="button" value="send" id="button" onClick={this.handleClick}></input>
                        </p>
                    </form>
                </div>
            )
        }
    }
    
    export default Chat
    
    groups\u forums\u channel.ex中的Module
    ChatSample.groupsformschannel
    是默认自动生成的模板


    我想完成的任务的一个简要总结是,用户消息应该广播给连接到频道的所有成员。

    错误出现在我的elixir代码中,
    组论坛频道。ex
    我应该包含此代码来处理传入消息

      def handle_in("new_msg", %{"body" => body}, socket) do
        broadcast socket, "new_msg", %{body: body}
        {:noreply, socket}
      end
    
    

    你能从这面TS墙中提取引起错误的部分(连接?)吗?谢谢,终于找到了错误。它在我的长生不老药代码中。
      def handle_in("new_msg", %{"body" => body}, socket) do
        broadcast socket, "new_msg", %{body: body}
        {:noreply, socket}
      end