# wechat-chat **Repository Path**: ericzyh/wechat-chat ## Basic Information - **Project Name**: wechat-chat - **Description**: 微信小程序版聊天室 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-10-09 - **Last Updated**: 2026-01-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # wechat-chat 本项目使用 [Gorilla WebSocket](https://github.com/gorilla/websocket) 作为聊天室后台 , Gorilla WebSocket 基于go语言开发,提供的demo实例中有聊天室源码,不需要任何修改就能生成一个聊天室项目(包含后台+web前台) demo: [http://121.42.51.70:8080](http://121.42.51.70:8080) ##一、聊天室服务搭建步骤: *如果不想搭建服务器,可以跳过这个步骤,直接使用我的服务* 1. 安装 [golang](https://golang.org/) , 安装1.6以上版本,低版本问题较多。*注:下载golang需要翻墙* 2. 安装Gorilla WebSocket模块 ``` go get github.com/gorilla/websocket ``` 3. 启动聊天室 ``` $ go get github.com/gorilla/websocket $ cd `go list -f '{{.Dir}}' github.com/gorilla/ websocket/examples/chat` $ go run *.go ``` 4. web客户端 访问:http://ip:8080 ##二、微信小程序客户端 1. git clone https://github.com/ericzyh/wechat-chat.git 2. 使用[微信web开发者工具](https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/devtools.html)导入项目 3. 修改服务地址 wechat-chat/utils/websockets.js 行1 ##三、小程序开发问题 (Q&A) 1. 如何通过js获取到某个组件? (发送消息后,清空输入框) A: 2. text存英文超过屏幕宽度后,会出现横向滚动条? A: 和css一样加上样式:```word-break:break-all;``` 3. 有没有办法在view里通过js动态加入view? A: ##四、todo 1. 发送消息后,清空输入框 2. 名字可点击,实现1v1通讯 3. 加入聊天间