40 lines
4.2 KiB
JSON
40 lines
4.2 KiB
JSON
{
|
||
"slug": "idcardinput",
|
||
"curated": true,
|
||
"mode": "single",
|
||
"examples": [
|
||
{
|
||
"id": "idcardinput-ex-1",
|
||
"title": "基础用法",
|
||
"titleSrc": "",
|
||
"desc": "",
|
||
"html": "<div class=\"kole-page\">\n <h2 class=\"kole-h2\">IDCardInput 身份证输入</h2>\n <p class=\"kole-desc\">18 位校验(含校验位)、自动提取出生日期与性别。</p>\n <div class=\"kole-demo\">\n <div class=\"kole-demo__title\">基础用法</div>\n <div class=\"kole-idcard\" id=\"idcard\">\n <div class=\"kole-idcard-field\" id=\"field\">\n <input class=\"kole-idcard-input\" id=\"input\" role=\"group\" maxlength=\"18\" placeholder=\"请输入 18 位身份证号\" />\n </div>\n <div class=\"kole-idcard-info\" id=\"info\" style=\"display:none\"></div>\n <div class=\"kole-idcard-tip\" id=\"tip\">示例:11010119900307657X</div>\n </div>\n </div>\n</div>",
|
||
"preview": {
|
||
"show": [
|
||
[
|
||
0
|
||
]
|
||
],
|
||
"hide": [],
|
||
"mode": "single"
|
||
},
|
||
"previewSafe": true,
|
||
"previewUnsafeReasons": [],
|
||
"source": "curated",
|
||
"code": {
|
||
"html": "<h2>IDCardInput 身份证输入</h2>\n<p>18 位校验(含校验位)、自动提取出生日期与性别。</p>\n<div>基础用法</div>\n<div class=\"kole-idcard\" id=\"idcard\">\n <div class=\"kole-idcard-field\">\n <input class=\"kole-idcard-input\" role=\"group\" maxlength=\"18\" placeholder=\"请输入 18 位身份证号\" />\n </div>\n <div class=\"kole-idcard-info\" style=\"display:none\"></div>\n <div class=\"kole-idcard-tip\">示例:11010119900307657X</div>\n</div>",
|
||
"jsx": "import { useState } from 'react';\nimport { KoleIDCardInput } from 'kole-ui/react';\n\nfunction Demo() {\n const [id, setId] = useState('');\n return (\n <KoleIDCardInput\n modelValue={id}\n placeholder=\"请输入 18 位身份证号\"\n onChange={setId}\n />\n );\n}",
|
||
"vue3": "<template>\n <KoleIDCardInput v-model=\"id\" placeholder=\"请输入 18 位身份证号\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue';\nimport { KoleIDCardInput } from 'kole-ui/vue3';\n\nconst id = ref('');\n</script>",
|
||
"vue2": "<template>\n <div>\n <KoleIDCardInput v-model=\"id\" placeholder=\"请输入 18 位身份证号\" />\n </div>\n</template>\n\n<script>\nimport { KoleIDCardInput } from 'kole-ui/vue2';\n\nexport default {\n components: { KoleIDCardInput },\n data() {\n return { id: '' };\n }\n};\n</script>",
|
||
"tsx": "import { useState } from 'react';\nimport { KoleIDCardInput } from 'kole-ui/react';\n\ntype IDCardValue = string;\nconst PLACEHOLDER: string = '请输入 18 位身份证号';\n\nfunction IDCardDemo(): JSX.Element {\n const [id, setId] = useState<IDCardValue>('');\n return (\n <KoleIDCardInput\n modelValue={id}\n placeholder={PLACEHOLDER}\n onChange={setId}\n />\n );\n}\n\nexport default IDCardDemo;",
|
||
"vue3ts": "<template>\n <KoleIDCardInput v-model=\"id\" :placeholder=\"placeholder\" />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { KoleIDCardInput } from 'kole-ui/vue3';\n\ntype IDCardValue = string;\n\nconst placeholder: string = '请输入 18 位身份证号';\nconst id = ref<IDCardValue>('');\n</script>",
|
||
"vue2ts": "<template>\n <div>\n <KoleIDCardInput v-model=\"id\" :placeholder=\"placeholder\" />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport { KoleIDCardInput } from 'kole-ui/vue2';\n\ntype IDCardValue = string;\n\nexport default Vue.extend({\n components: { KoleIDCardInput },\n data(): { id: IDCardValue; placeholder: string } {\n return { id: '', placeholder: '请输入 18 位身份证号' };\n },\n});\n</script>"
|
||
},
|
||
"notes": [
|
||
"依据 frameworks/IDCardInput.html:19-22 的 placeholder=\"请输入 18 位身份证号\" 与 :22 提示文案「示例:11010119900307657X」;组件 prop 见 frameworks/IDCardInput.jsx 的 modelValue/placeholder/onChange",
|
||
"TS 形态依据 TS-VARIANTS.md:tsx 用 useState<IDCardValue> + type IDCardValue 别名把领域语义写进类型;vue3ts/vue2ts 用 <script lang=\"ts\"> + ref<IDCardValue>();不引入 kole-ui 的类型(本仓库不随包发布 .d.ts)"
|
||
]
|
||
}
|
||
]
|
||
}
|