Loading...
Loading...
Compare original and translation side by side
npm i tdesign-miniprogram -S --productionnpm i tdesign-miniprogram -S --production"style": "v2"app.json"style": "v2"settingproject.config.json{
"setting": {
"packNpmManually": true,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./"
}
]
}
}setting{
"setting": {
"packNpmManually": true,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./"
}
]
}
}{
"paths": {
"tdesign-miniprogram/*": [
"./miniprogram/miniprogram_npm/tdesign-miniprogram/*"
]
}
}After modifying project.config.json, build npm in WeChat DevTools:Tools - Build npm
After successful build, checkCompile JS to ES5
{
"paths": {
"tdesign-miniprogram/*": [
"./miniprogram/miniprogram_npm/tdesign-miniprogram/*"
]
}
}修改project.config.json后,在微信开发者工具中执行工具 - 构建npm
构建成功后,勾选将JS编译为ES5
{
"usingComponents": {
"t-button": "tdesign-miniprogram/button/button"
}
}<t-button theme="primary">Button</t-button>{
"usingComponents": {
"t-button": "tdesign-miniprogram/button/button"
}
}<t-button theme="primary">Button</t-button>| Component | Description | Import Path |
|---|---|---|
| Button | Button | |
| Divider | Divider | |
| Fab | Floating Action Button | |
| Icon | Icon | |
| Layout | Layout | |
| Link | Link | |
| 组件 | 说明 | 引入路径 |
|---|---|---|
| Button | 按钮 | |
| Divider | 分割线 | |
| Fab | 悬浮操作按钮 | |
| Icon | 图标 | |
| Layout | 布局 | |
| Link | 链接 | |
| Component | Description | Import Path |
|---|---|---|
| BackTop | Back to Top | |
| Drawer | Drawer | |
| Indexes | Index List | |
| Navbar | Navigation Bar | |
| SideBar | Side Navigation | |
| Steps | Steps | |
| TabBar | Bottom Tab Bar | |
| Tabs | Tabs | |
| 组件 | 说明 | 引入路径 |
|---|---|---|
| BackTop | 返回顶部 | |
| Drawer | 抽屉 | |
| Indexes | 索引列表 | |
| Navbar | 导航栏 | |
| SideBar | 侧边导航 | |
| Steps | 步骤条 | |
| TabBar | 底部标签栏 | |
| Tabs | 标签页 | |
| Component | Description | Import Path |
|---|---|---|
| Calendar | Calendar | |
| Cascader | Cascader | |
| CheckBox | Checkbox | |
| DateTimePicker | Date Time Picker | |
| Input | Input | |
| Picker | Picker | |
| Radio | Radio | |
| Rate | Rate | |
| Search | Search | |
| Slider | Slider | |
| Stepper | Stepper | |
| Switch | Switch | |
| Textarea | Textarea | |
| TreeSelect | Tree Select | |
| Upload | Upload | |
| Form | Form | |
| 组件 | 说明 | 引入路径 |
|---|---|---|
| Calendar | 日历 | |
| Cascader | 级联选择器 | |
| CheckBox | 复选框 | |
| DateTimePicker | 日期时间选择器 | |
| Input | 输入框 | |
| Picker | 选择器 | |
| Radio | 单选框 | |
| Rate | 评分 | |
| Search | 搜索框 | |
| Slider | 滑块 | |
| Stepper | 步进器 | |
| Switch | 开关 | |
| Textarea | 多行输入框 | |
| TreeSelect | 树形选择 | |
| Upload | 上传 | |
| Form | 表单 | |
| Component | Description | Import Path |
|---|---|---|
| Avatar | Avatar | |
| Badge | Badge | |
| Cell | Cell | |
| Collapse | Collapse | |
| CountDown | Countdown | |
| Empty | Empty State | |
| Footer | Footer | |
| Grid | Grid | |
| Image | Image | |
| ImageViewer | Image Viewer | |
| Progress | Progress | |
| Result | Result | |
| Skeleton | Skeleton | |
| Sticky | Sticky | |
| Swiper | Swiper | |
| Table | Table | |
| Tag | Tag | |
| List | List | |
| 组件 | 说明 | 引入路径 |
|---|---|---|
| Avatar | 头像 | |
| Badge | 徽标 | |
| Cell | 单元格 | |
| Collapse | 折叠面板 | |
| CountDown | 倒计时 | |
| Empty | 空状态 | |
| Footer | 页脚 | |
| Grid | 宫格 | |
| Image | 图片 | |
| ImageViewer | 图片预览 | |
| Progress | 进度条 | |
| Result | 结果页 | |
| Skeleton | 骨架屏 | |
| Sticky | 吸顶 | |
| Swiper | 轮播图 | |
| Table | 表格 | |
| Tag | 标签 | |
| List | 列表 | |
| Component | Description | Import Path |
|---|---|---|
| ActionSheet | Action Sheet | |
| Dialog | Dialog | |
| DropdownMenu | Dropdown Menu | |
| Guide | Guide | |
| Loading | Loading | |
| Message | Message | |
| NoticeBar | Notice Bar | |
| Overlay | Overlay | |
| Popup | Popup | |
| PullDownRefresh | Pull Down Refresh | |
| SwipeCell | Swipe Cell | |
| Toast | Toast | |
| 组件 | 说明 | 引入路径 |
|---|---|---|
| ActionSheet | 操作面板 | |
| Dialog | 对话框 | |
| DropdownMenu | 下拉菜单 | |
| Guide | 引导提示 | |
| Loading | 加载提示 | |
| Message | 消息提示 | |
| NoticeBar | 通知栏 | |
| Overlay | 遮罩层 | |
| Popup | 弹出层 | |
| PullDownRefresh | 下拉刷新 | |
| SwipeCell | 滑动单元格 | |
| Toast | 轻提示 | |
| Component | Description | Import Path |
|---|---|---|
| ChatList | Chat List | |
| ChatMessage | Chat Message | |
| ChatSender | Chat Sender | |
| ChatContent | Chat Content | |
| ChatActionbar | Chat Action Bar | |
| ChatLoading | Chat Loading | |
| ChatMarkdown | Chat Markdown | |
| ChatThinking | Chat Thinking | |
| Attachments | Attachments | |
| 组件 | 说明 | 引入路径 |
|---|---|---|
| ChatList | 聊天列表 | |
| ChatMessage | 聊天消息 | |
| ChatSender | 聊天输入框 | |
| ChatContent | 聊天内容 | |
| ChatActionbar | 聊天操作栏 | |
| ChatLoading | 聊天加载状态 | |
| ChatMarkdown | 聊天Markdown渲染 | |
| ChatThinking | 思考状态提示 | |
| Attachments | 附件选择器 | |
<!-- Basic Buttons -->
<t-button theme="primary" size="large">Primary Button</t-button>
<t-button theme="light" size="large">Light Button</t-button>
<t-button size="large">Default Button</t-button>
<!-- Outline and Text Buttons -->
<t-button theme="primary" size="large" variant="outline"
>Outline Button</t-button
>
<t-button theme="primary" size="large" variant="text">Text Button</t-button>
<!-- Icon Button -->
<t-button
theme="primary"
icon="app"
content="Icon Button"
size="large"
></t-button>
<!-- Loading State -->
<t-button theme="primary" size="large" loading>Loading</t-button>
<!-- Disabled State -->
<t-button theme="primary" size="large" disabled>Disabled</t-button>
<!-- Block Button -->
<t-button theme="primary" size="large" block>Block Button</t-button>
<!-- Ghost Button (transparent background) -->
<t-button theme="primary" ghost size="large">Ghost Button</t-button><!-- 基础按钮 -->
<t-button theme="primary" size="large">主按钮</t-button>
<t-button theme="light" size="large">浅色按钮</t-button>
<t-button size="large">默认按钮</t-button>
<!-- 轮廓与文字按钮 -->
<t-button theme="primary" size="large" variant="outline"
>轮廓按钮</t-button
>
<t-button theme="primary" size="large" variant="text">文字按钮</t-button>
<!-- 图标按钮 -->
<t-button
theme="primary"
icon="app"
content="图标按钮"
size="large"
></t-button>
<!-- 加载状态 -->
<t-button theme="primary" size="large" loading>加载中</t-button>
<!-- 禁用状态 -->
<t-button theme="primary" size="large" disabled>已禁用</t-button>
<!-- 块级按钮 -->
<t-button theme="primary" size="large" block>块级按钮</t-button>
<!-- 幽灵按钮(透明背景) -->
<t-button theme="primary" ghost size="large">幽灵按钮</t-button>{
"usingComponents": {
"t-input": "tdesign-miniprogram/input/input"
}
}<t-input
label="Label"
placeholder="Please enter"
value="{{value}}"
bind:change="onChange"
/>{
"usingComponents": {
"t-input": "tdesign-miniprogram/input/input"
}
}<t-input
label="标签"
placeholder="请输入"
value="{{value}}"
bind:change="onChange"
/>{
"usingComponents": {
"t-dialog": "tdesign-miniprogram/dialog/dialog"
}
}<t-dialog
visible="{{visible}}"
title="Dialog Title"
content="Dialog content"
confirm-btn="Confirm"
cancel-btn="Cancel"
bind:confirm="onConfirm"
bind:cancel="onCancel"
/>{
"usingComponents": {
"t-dialog": "tdesign-miniprogram/dialog/dialog"
}
}<t-dialog
visible="{{visible}}"
title="对话框标题"
content="对话框内容"
confirm-btn="确认"
cancel-btn="取消"
bind:confirm="onConfirm"
bind:cancel="onCancel"
/>import Toast from 'tdesign-miniprogram/toast/index';
Toast({
context: this,
selector: '#t-toast',
message: 'Toast message',
});import Toast from 'tdesign-miniprogram/toast/index';
Toast({
context: this,
selector: '#t-toast',
message: '提示信息',
});{
"usingComponents": {
"t-chat-list": "tdesign-miniprogram/chat-list/chat-list",
"t-chat-message": "tdesign-miniprogram/chat-message/chat-message",
"t-chat-sender": "tdesign-miniprogram/chat-sender/chat-sender"
}
}<t-chat-list layout="single">
<t-chat-message
avatar="{{item.avatar}}"
name="{{item.name}}"
content="{{item.content}}"
role="{{item.role}}"
/>
<view slot="footer">
<t-chat-sender bind:send="onSend" />
</view>
</t-chat-list>Component({
data: {
messages: [
{
role: 'user',
content: [{ type: 'text', data: 'Hello' }],
},
{
role: 'assistant',
content: [{ type: 'text', data: 'Hello! How can I help you?' }],
},
],
},
methods: {
onSend(e) {
const { value } = e.detail;
// Handle send message
},
},
});{
"usingComponents": {
"t-chat-list": "tdesign-miniprogram/chat-list/chat-list",
"t-chat-message": "tdesign-miniprogram/chat-message/chat-message",
"t-chat-sender": "tdesign-miniprogram/chat-sender/chat-sender"
}
}<t-chat-list layout="single">
<t-chat-message
avatar="{{item.avatar}}"
name="{{item.name}}"
content="{{item.content}}"
role="{{item.role}}"
/>
<view slot="footer">
<t-chat-sender bind:send="onSend" />
</view>
</t-chat-list>Component({
data: {
messages: [
{
role: 'user',
content: [{ type: 'text', data: '你好' }],
},
{
role: 'assistant',
content: [{ type: 'text', data: '你好!请问有什么可以帮你的?' }],
},
],
},
methods: {
onSend(e) {
const { value } = e.detail;
// 处理发送消息逻辑
},
},
});<t-button style="color: red">Custom Style</t-button>
<t-button custom-style="color: red">Custom Style</t-button><t-button style="color: red">自定义样式按钮</t-button>
<t-button custom-style="color: red">自定义样式按钮</t-button>.t-button--primary {
background-color: navy;
}styleIsolationComponent({
options: {
styleIsolation: 'shared',
},
});.t-button--primary {
background-color: navy;
}styleIsolationComponent({
options: {
styleIsolation: 'shared',
},
});<t-button t-class="my-button-class">Button</t-button>.my-button-class {
background-color: navy !important;
}<t-button t-class="my-button-class">按钮</t-button>.my-button-class {
background-color: navy !important;
}page {
--td-button-primary-bg-color: #0052d9;
--td-button-border-radius: 8rpx;
}page {
--td-button-primary-bg-color: #0052d9;
--td-button-border-radius: 8rpx;
}{
"darkmode": true
}{
"darkmode": true
}app.wxss@import 'miniprogram_npm/tdesign-miniprogram/common/style/theme/_index.wxss';app.wxss@import 'miniprogram_npm/tdesign-miniprogram/common/style/theme/_index.wxss';.text {
color: var(--td-text-color-secondary);
}.text {
color: var(--td-text-color-secondary);
}custom-tab-barroot-portal.page<view class="page">
<t-tab-bar />
</view>custom-tab-barroot-portal.page<view class="page">
<t-tab-bar />
</view>references/references/ReadRead^2.12.0"style": "v2"app.json^2.12.0"style": "v2"