37 lines
4.4 KiB
JSON
37 lines
4.4 KiB
JSON
{
|
|
"slug": "switchgroup",
|
|
"mode": "single",
|
|
"examples": [
|
|
{
|
|
"id": "switchgroup-ex-1",
|
|
"title": "基础用法",
|
|
"titleSrc": "",
|
|
"desc": "",
|
|
"html": "<div class=\"kole-panel\">\n <div class=\"kole-switchgroup\" id=\"app\" role=\"group\"></div>\n</div>",
|
|
"preview": {
|
|
"show": [
|
|
[
|
|
0
|
|
]
|
|
],
|
|
"hide": [],
|
|
"mode": "single"
|
|
},
|
|
"previewSafe": true,
|
|
"previewUnsafeReasons": [],
|
|
"source": "curated",
|
|
"code": {
|
|
"html": "<div class=\"kole-switchgroup\" role=\"group\"></div>",
|
|
"jsx": "import { useState } from 'react';\nimport { KoleSwitchGroup } from 'kole-ui/react';\n\nconst options = [\n { label: '邮件通知', value: 'mail', desc: '接收系统邮件提醒' },\n { label: '短信通知', value: 'sms', desc: '重要变更发送短信' },\n { label: '站内信', value: 'inbox', desc: '工作台消息中心' }\n];\n\nexport default function NotifySettingGroup() {\n const [value, setValue] = useState(['mail', 'inbox']);\n return (\n <KoleSwitchGroup\n title=\"通知设置\"\n selectAll\n options={options}\n value={value}\n onChange={setValue}\n />\n );\n}",
|
|
"vue3": "<template>\n <KoleSwitchGroup v-model=\"value\" title=\"通知设置\" select-all :options=\"options\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue';\nimport { KoleSwitchGroup } from 'kole-ui/vue3';\n\nconst options = [\n { label: '邮件通知', value: 'mail', desc: '接收系统邮件提醒' },\n { label: '短信通知', value: 'sms', desc: '重要变更发送短信' },\n { label: '站内信', value: 'inbox', desc: '工作台消息中心' }\n];\n\nconst value = ref(['mail', 'inbox']);\n</script>",
|
|
"vue2": "<template>\n <KoleSwitchGroup v-model=\"value\" title=\"通知设置\" select-all :options=\"options\" />\n</template>\n\n<script>\nimport { KoleSwitchGroup } from 'kole-ui/vue2';\n\nexport default {\n name: 'SwitchGroupBasic',\n components: { KoleSwitchGroup },\n data() {\n return {\n options: [\n { label: '邮件通知', value: 'mail', desc: '接收系统邮件提醒' },\n { label: '短信通知', value: 'sms', desc: '重要变更发送短信' },\n { label: '站内信', value: 'inbox', desc: '工作台消息中心' }\n ],\n value: ['mail', 'inbox']\n };\n }\n};\n</script>",
|
|
"tsx": "import { useState } from 'react';\nimport { KoleSwitchGroup } from 'kole-ui/react';\n\nconst options = [\n { label: '邮件通知', value: 'mail', desc: '接收系统邮件提醒' },\n { label: '短信通知', value: 'sms', desc: '重要变更发送短信' },\n { label: '站内信', value: 'inbox', desc: '工作台消息中心' }\n];\n\nexport default function NotifySettingGroup(): JSX.Element {\n const [value, setValue] = useState(['mail', 'inbox']);\n return (\n <KoleSwitchGroup\n title=\"通知设置\"\n selectAll\n options={options}\n value={value}\n onChange={setValue}\n />\n );\n}",
|
|
"vue3ts": "<template>\n\n <KoleSwitchGroup v-model=\"value\" title=\"通知设置\" select-all :options=\"options\" />\n</template>\n\n<script setup lang=\"ts\">\nimport { KoleSwitchGroup } from 'kole-ui/vue3';\n\nconst demoTitle = ref<string>('基础用法');\nconst options = [\n { label: '邮件通知', value: 'mail', desc: '接收系统邮件提醒' },\n { label: '短信通知', value: 'sms', desc: '重要变更发送短信' },\n { label: '站内信', value: 'inbox', desc: '工作台消息中心' }\n];\n\nconst value = ref(['mail', 'inbox']);\n</script>",
|
|
"vue2ts": "<template>\n\n <KoleSwitchGroup v-model=\"value\" title=\"通知设置\" select-all :options=\"options\" />\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport { KoleSwitchGroup } from 'kole-ui/vue2';\n\nexport default {\n name: 'SwitchGroupBasic',\n components: { KoleSwitchGroup },\n data(): Record<string, unknown> {\n return {\n options: [\n { label: '邮件通知', value: 'mail', desc: '接收系统邮件提醒' },\n { label: '短信通知', value: 'sms', desc: '重要变更发送短信' },\n { label: '站内信', value: 'inbox', desc: '工作台消息中心' }\n ],\n value: ['mail', 'inbox']\n };\n }\n};\n</script>"
|
|
},
|
|
"notes": "依据 frameworks/SwitchGroup.html:17-21 DATA 三项实参(邮件/短信/站内信)、:26 标题「通知设置」、:27 全选开关、:41-47 单项切换"
|
|
}
|
|
],
|
|
"curated": true
|
|
}
|