Skip to content

Commit be39c9e

Browse files
committed
Merge branch 'feature/chat' of https://github.com/Tencent/tdesign-miniprogram into feature/chat
2 parents a4732a8 + dcf9d84 commit be39c9e

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

packages/tdesign-miniprogram-chat/site/docs/getting-started.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,88 @@ description: TDesign 微信小程序 AI Chat 组件库。
44
spline: explain
55
---
66

7+
## 预览
8+
9+
小程序组件示例小程序,请使用微信扫码预览 ↓
10+
<br/>
11+
12+
<img width="260" src="https://tdesign.gtimg.com/site/qrcode.jpeg" />
13+
14+
## 使用之前
15+
16+
使用前,请确保你已经学习过微信官方的 [小程序简易教程](https://developers.weixin.qq.com/miniprogram/dev/framework/)[自定义组件介绍](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/)
17+
18+
## 安装
19+
20+
### 使用 NPM
21+
22+
小程序已经支持使用 NPM 安装第三方包,详见 [NPM 支持](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html?search-key=npm)
23+
24+
```bash
25+
npm i tdesign-miniprogram -S --production
26+
```
27+
28+
> 安装完之后,需要在微信开发者工具中对 npm 进行构建:`工具 - 构建 npm`。(构建时若出现`NPM packages not found`字样,请到 `project.config.json` 文件补充 `packNpmManually``packNpmRelationList` 配置项,具体见[NPM 支持](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html?search-key=npm)
29+
30+
31+
> 构建成功后勾选 `将 JS 编译成 ES5`
32+
> <br/>
33+
><img width="200" src="https://tdesign.gtimg.com/miniprogram/docs/getting-started.png" />
34+
35+
36+
## 修改 app.json
37+
38+
`app.json` 中的 `"style": "v2"` 移除。
39+
40+
> 因为 [该配置](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#style) 表示启用新版组件样式,将会导致 TDesign 的组件样式错乱。
41+
42+
## 修改 tsconfig.json
43+
如果使用`typescript`开发,需要修改`tsconfig.json`指定`paths`
44+
```json
45+
{
46+
"paths": {
47+
"tdesign-miniprogram/*":["./miniprogram/miniprogram_npm/tdesign-miniprogram/*"]
48+
}
49+
}
50+
```
51+
52+
## 使用组件
53+
54+
以聊天组件为例,只需要在 `JSON` 文件中引入聊天对应的自定义组件即可
55+
56+
```json
57+
{
58+
"usingComponents": {
59+
"t-chat": "tdesign-miniprogram/chat/chat",
60+
"t-chat-message": "tdesign-miniprogram/chat-message/chat-message",
61+
"t-chat-sender": "tdesign-miniprogram/chat-sender/chat-sender"
62+
}
63+
}
64+
```
65+
66+
接着就可以在 wxml 中直接使用组件
67+
68+
```html
69+
<t-chat layout="single">
70+
<t-chat-message avatar="{{item.avatar}}" name="{{item.name}}" content="{{item.content}}" role="{{item.role}}" />
71+
<view slot="footer">
72+
<t-chat-sender bind:send="onSend" />
73+
</view>
74+
</t-chat>
75+
```
76+
77+
## 在开发者工具中预览
78+
79+
```bash
80+
# 安装项目依赖
81+
npm install
82+
83+
# 执行组件编译
84+
npm run dev
85+
```
86+
87+
打开[微信开发者工具](https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html),把`_example`目录添加进去就可以预览示例了。
88+
89+
## 基础库版本
90+
91+
最低基础库版本`^2.6.5`

0 commit comments

Comments
 (0)