================ 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: ``` ``` -------------------------------- 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: ``` ``` -------------------------------- 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: ``` ``` -------------------------------- 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: ``` ``` -------------------------------- 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: ``` ``` -------------------------------- 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: ``` ``` -------------------------------- 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: ``` ``` -------------------------------- 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: ``` ``` -------------------------------- 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?.() } ```