================
CODE SNIPPETS
================
TITLE: Example Script Setup for xWeekbar (Vue)
DESCRIPTION: The
```
--------------------------------
TITLE: Script for UNIAPP Badge Example Page
DESCRIPTION: Provides the minimal JavaScript script block required for the UNIAPP example page component. It defines the component's reactive data properties and includes the standard `onLoad` lifecycle hook, although no badge-specific logic is implemented in this basic example.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/badge.md#_snippet_1
LANGUAGE: JavaScript
CODE:
```
```
--------------------------------
TITLE: Example x-mention Logic Script (UTS)
DESCRIPTION: Provides the UTS script logic (`script setup`) for the example template. It uses Vue 3 Composition API features (`ref`, `computed`) to manage UI state (drawer visibility, input value, mention list, chat messages) and component references. It defines event handlers (`onmention`, `cellClick`, `beforeRemove`, `removemention`, `onconfirm`) to interact with the `x-mention` component and simulate a mention selection workflow.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/mention.md#_snippet_2
LANGUAGE: UTS
CODE:
```
import { ref } from "vue"
type PENGYOU_TYPE = {
name : string,
id : string
}
const show = ref(false)
const keyword = ref("")
const mention = ref(null)
const pengyouList = ref([])
const pengyouListNames = computed(():string[] => pengyouList.value.map((el:PENGYOU_TYPE):string=> ('@'+el.name)))
const chat = ref([])
const tags = ref([])
// 添加虚拟数据
for (let i = 0; i < 10; i++) {
pengyouList.value.push({
name: "朋友" + i,
id: i.toString()
} as PENGYOU_TYPE)
}
const onmention = () => {
show.value = true;
}
const cellClick = (str : string) => {
if(mention.value==null) return;
keyword.value += str + ' '
show.value = false;
mention.value!.setFoucus(true)
tags.value.push(str)
}
//删除前需要校验当前删除的标签是不是朋友标签,因为如果用户把光标移动有名称内删除,打乱了标签,其实已经不构成是标签了,就不需要删除了.
const beforeRemove = (tag : string) : boolean => {
let index = pengyouList.value.findIndex((el : PENGYOU_TYPE) : boolean => el.name == tag)
console.log("即将删除标签:", tag, index > 1 ? '是' : '否')
return index > -1
}
const removemention = (tag : string) => {
console.log("被删除标签:", tag)
}
const onconfirm = (nowval:string)=>{
chat.value.push(nowval)
keyword.value = ''
}
```
--------------------------------
TITLE: Example Page Script (JavaScript)
DESCRIPTION: This JavaScript snippet provides the script logic for the example page. It defines a 'showModal' data property to control the visibility state of the x-action-modal and sets it to 'true' in the 'onReady' lifecycle hook, causing the modal to display when the page is ready.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/action-modal.md#_snippet_2
LANGUAGE: JavaScript
CODE:
```
```
--------------------------------
TITLE: Example Implementation Template HTML
DESCRIPTION: Full template code for an example page demonstrating various uses of x-dropdown-menu. It includes using v-model for control, nesting x-dropdown-item components with custom content, handling different positioning modes (fixed and static), and conditional rendering directives for platform compatibility.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/dropdown-menu.md#_snippet_1
LANGUAGE: HTML
CODE:
```
下拉菜单 dropdownMenu
提供static和fiexd两种位置方式。内容完全通过插槽自由布局。x-dropdown-menu 中的render="true"后动画会消失
因自由度非常高,你可以自由布局最大高度是否滚动内容。
关闭
自己添加scrollview等实现页脚功能.
内容层的高度是自动高。不需要额外设置。
内容层的高度是自动高。不需要额外设置。
正文是静态,弹出时,菜单不会置顶在页面顶部。
这里由用户自由布局内容,实现逻辑。
你还可以实现更多更复杂的功能.
完全插槽实现灵活度极高。
```
--------------------------------
TITLE: Script Logic for x-indexbar Example Page JS/UTS
DESCRIPTION: Contains the script logic for the example page using the x-indexbar component. It imports sample data and a store, initializes component data, and defines a computed property to check the current theme mode using the xStore.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/indexbar.md#_snippet_2
LANGUAGE: JavaScript
CODE:
```
```
--------------------------------
TITLE: Styling tmui4 TextCloud Example Page (SCSS)
DESCRIPTION: Provides an empty style block for the example page using SCSS. It currently contains no specific styles but serves as a placeholder for adding component or page-level styling.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/text-cloud.md#_snippet_3
LANGUAGE: SCSS
CODE:
```
```
--------------------------------
TITLE: Example Usage of x-icon Component - HTML
DESCRIPTION: Comprehensive example demonstrating the `x-icon` component's features in a Uni-app template, including setting icons by `name`, rotating icons with the `rotation` prop, changing color with the `color` prop, and applying a spin animation with the `spin` prop. Includes conditional rendering for different platforms.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/icon.md#_snippet_1
LANGUAGE: html
CODE:
```
图标 Icon
使用开源图标remixicon:https://remixicon.com/
name:只要名称就行,不要ri-前缀,比如router-line
旋转 Rotation
颜色 color
更多属性见文档
动画 Spin
```
--------------------------------
TITLE: Example Page Styles (SCSS)
DESCRIPTION: This is the style block for the example page using SCSS. The block is currently empty, indicating that no specific styles are defined or applied within this section for the page or its components.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/action-modal.md#_snippet_3
LANGUAGE: SCSS
CODE:
```
```
--------------------------------
TITLE: Example Logic Script JavaScript
DESCRIPTION: JavaScript code providing the data and methods for the example page template. It manages the active state of the dropdown menu using the `activeIndex` data property and defines an `onchange` method to handle the dropdown's change event, logging the selected index, key name, and status.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/dropdown-menu.md#_snippet_2
LANGUAGE: JavaScript
CODE:
```
```
--------------------------------
TITLE: Example Styles for xCountdown Page (SCSS)
DESCRIPTION: The style section for the example UNIAPP page using the `x-countdown` component. It specifies the language as SCSS but contains no actual styles, indicating that styling relies on default component styles, inline styles, or styles defined elsewhere.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/countdown.md#_snippet_3
LANGUAGE: SCSS
CODE:
```
```
--------------------------------
TITLE: Component Script Structure - UTS
DESCRIPTION: The script section for the Uni-app page example, defining the component's data and methods placeholders. Written in UTS, it provides the basic structure but doesn't contain specific logic directly related to the `x-icon` component's props or events in this minimal example.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/icon.md#_snippet_2
LANGUAGE: uts
CODE:
```
```
--------------------------------
TITLE: Example Page Script with TMUI4 Javascript
DESCRIPTION: This is the basic script block for the example page using the x-rate component. It exports a default Vue component object with an empty data function, serving as a minimal setup for the page.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/rate.md#_snippet_1
LANGUAGE: javascript
CODE:
```
```
--------------------------------
TITLE: Example Usage of x-sign-board Component - Template
DESCRIPTION: This snippet shows how to integrate the x-sign-board component into a Vue template. It includes examples of setting its height and binding its ref, as well as demonstrating interaction buttons (Save, Check, Clear) and usage within a modal. It also shows how to display the saved image.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/sign-board.md#_snippet_0
LANGUAGE: template
CODE:
```
签名板 SignBoard
提供高性能流畅性的原生绘制
保存图片
是否签名
清除
演示在弹层内
打开
加载中
点击上方保存图片预览
```
--------------------------------
TITLE: Rendering tmui4 TextCloud Example Page (Vue Template)
DESCRIPTION: Provides a complete template structure for an example page demonstrating the `x-text-cloud` component. It includes conditional rendering for `APP` and `MP-WEIXIN` platforms, basic layout components (`x-sheet`, `x-text`), and two instances of `x-text-cloud` using different data lists (`list` and `list2`).
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/text-cloud.md#_snippet_1
LANGUAGE: HTML
CODE:
```
词云 TtextCloud
把文字集中一起随机绘制,权重高的会突显变大,并居中显示。
```
--------------------------------
TITLE: Example Style Block SCSS
DESCRIPTION: An empty style block placeholder for component-specific styles, configured to use SCSS. In this particular example, no custom styles are defined within the block.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/msg-notice.md#_snippet_3
LANGUAGE: SCSS
CODE:
```
```
--------------------------------
TITLE: Example x-mention Usage Template (UTS/UNIAPP)
DESCRIPTION: Provides a full UNIAPP template example demonstrating the use of the `x-mention` component. It includes conditional compilation for different platforms, basic layout components (`x-sheet`, `x-text`), iteration (`v-for`), data binding (`v-model`), event handling (`@confirm`, `@mention`, `@beforeRemove`, `@removemention`), referencing the component (`ref`), and integrating with a selection drawer (`x-drawer`) for mentioning users.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/mention.md#_snippet_1
LANGUAGE: html
CODE:
```
提及 xMention
此组件的输入体验与微信基本相符,体验比较完善它不与选择视图绑定,通过事件控制将会完美的支持自定界面.
可以像微信一样选择朋友并在编辑朋友删除字符让之前选择的失效.然后继续选择,会在删除前和删除后通过事件通知.
```
--------------------------------
TITLE: Example Markdown Input String
DESCRIPTION: This string represents the markdown content assigned to the `str` data property, including headers, bold text, tables, and fenced code blocks (CSS, Javascript) to be rendered by the x-markdown component.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/markdown.md#_snippet_3
LANGUAGE: Markdown
CODE:
```
# 全局配置
## 介绍
本配置参数会影响整个app风格,请慎重配置,或者根据你的UI/UX设计师指示配置
**可以在任意位置导入并设置,立即生效,全局响应**\n**堙**
| This header | spans two | Header A |
|-------------|------------|----------|
| Cell A | Cell B | Cell C |
| Cell A | Cell B | Cell C |
| Cell A | Cell B | Cell C |
## CSS代码
\`\`\`css
<--!>输入内容
<\/uni-view>
\`\`\`
\`\`\`css
const highlight = "code";
\`\`\`
```
--------------------------------
TITLE: Basic xTree Component Usage - HTML
DESCRIPTION: Demonstrates the simplest way to use the x-tree component by including its tag in a template. This basic example shows the component inclusion without any specific props or event bindings.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/tree.md#_snippet_0
LANGUAGE: HTML
CODE:
```
```
--------------------------------
TITLE: Page Styling SCSS
DESCRIPTION: Provides a block for defining page-specific styles using SCSS syntax. This particular snippet is empty, indicating that no custom styles are applied in this example. Requires an SCSS compiler or preprocessor setup.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/watermark.md#_snippet_3
LANGUAGE: SCSS
CODE:
```
```
--------------------------------
TITLE: Example Style Block for xWeekbar (Vue)
DESCRIPTION: The
```
--------------------------------
TITLE: Using xBetweenTime Component with Data Binding - Vue/uni-app
DESCRIPTION: This code snippet demonstrates how to integrate and use the xBetweenTime component within a Vue/uni-app template. It shows binding the selected date range using `v-model` to the `newdata` variable and the formatted output string using `v-model:model-str` to the `nowVal` variable. It also sets explicit start and end dates and includes examples of using quick date buttons.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/between-time.md#_snippet_0
LANGUAGE: Vue/uni-app
CODE:
```
时间区间选择 xBetweenTime
快速的时间区间选择器,方便时间选择自动判断前后时间大小并校正。
打开时间
选中的值:{{newdata}}
经format的值:{{nowVal}}
赋值
设置快捷按钮
打开时间
```
--------------------------------
TITLE: Example Page Styling for x-float-drawer CSS
DESCRIPTION: This CSS snippet provides scoped styles for the example page components. It defines the '.heightani' class used in the template, setting up a CSS transition specifically for the 'height' property with a linear timing function to support the dynamic height adjustments driven by the JavaScript logic.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/float-drawer.md#_snippet_3
LANGUAGE: CSS
CODE:
```
```
--------------------------------
TITLE: Example Page Script for x-float-drawer JavaScript
DESCRIPTION: This script provides the logic for the example page using the x-float-drawer. It manages the drawer's visibility via the 'showFloat' data property and includes methods ('onbeforeclose', 'onmovestart', 'onmoveend', 'onheightChange') to handle events emitted by the drawer, specifically manipulating a DOM element's style based on the 'heightChange' event to create a dynamic animation.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/float-drawer.md#_snippet_2
LANGUAGE: JavaScript
CODE:
```
```
--------------------------------
TITLE: Example Usage Script for x-switch-slider (UTS Script)
DESCRIPTION: Provides the script logic for the example page using x-switch-slider in UNIAPP/UTS. It initializes sample data for a list of items, demonstrates populating the list in the beforeMount hook, and includes methods to handle slider open/close events (managing state for multiple sliders), menu item clicks (share, remove), main item clicks, and a special event to manage external scroll disabling. Uses UTSJSONObject for data structure.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/switch-slider.md#_snippet_2
LANGUAGE: UNIAPP/Vue/UTS Script
CODE:
```
```
--------------------------------
TITLE: Example Usage Template for xCountdown (UNIAPP Vue)
DESCRIPTION: Provides a complete UNIAPP template example showcasing the integration of `x-countdown` components. It includes conditional compilation directives, layout components (`x-sheet`, `x-text`, `x-button`), and two instances of `x-countdown` configured with different times, units, and formats. It also demonstrates controlling the countdown state (play, pause, reset) using buttons bound to data properties via `v-model:actions`.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/countdown.md#_snippet_1
LANGUAGE: HTML
CODE:
```
倒计时 xCountdown
倒计时,可以精确到秒,毫秒,尽量通过插槽来布局样式。
开始
暂停
重置
开始
暂停
重置
```
--------------------------------
TITLE: Example Vue Script with x-markdown Interaction
DESCRIPTION: This script demonstrates the data properties, lifecycle hooks, and methods used with the x-markdown component, including initializing markdown content, handling tag click events, simulating stream-like content updates, and appending text.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/markdown.md#_snippet_2
LANGUAGE: Javascript
CODE:
```
```
--------------------------------
TITLE: Example Vue Template Structure with x-markdown
DESCRIPTION: This template demonstrates integrating the x-markdown component within a UniApp page structure, using other tmx-ui components like x-sheet, x-text, and x-button, and handling conditional compilation for different platforms.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/markdown.md#_snippet_1
LANGUAGE: Vue
CODE:
```
富文本 markdown
它支持传入html,markdown格式等内容进行预览,同时也支持动态的相关格式内容解析(常见SSE流式内容更新赋值解析,可能标签被拆分再解析)
不管你传的是什么格式,建议遵循微信小程序的富文本所支持的标签。这样可以和另一个组件x-edite相互转换编辑和预览。
追加内容
```
--------------------------------
TITLE: Calling the Reset Method via Ref in UTS
DESCRIPTION: Provides an example in UTS (UTS is used for APP-specific script setup) demonstrating how to use a component ref (`ref='verify'`) to access the xSlideVerify instance and programmatically call its `reset` method, often triggered by user interaction like a button click.
SOURCE: https://github.com/tmzdy888/tmui4-doc/blob/main/slide-verify.md#_snippet_3
LANGUAGE: UTS
CODE:
```
const verify = ref(null)
const reset = () => {
if(verify.value==null) return;
verify.value?.reset?.()
}
```