| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509 |
- <template>
- <cl-page>
- <view class="p-3">
- <demo-item :label="t('基础用法')">
- <cl-cascader v-model="form.cascader1" :options="options"></cl-cascader>
- </demo-item>
- <demo-item :label="t('带索引、地区选择')">
- <cl-cascader v-model="form.cascader2" :options="options2"></cl-cascader>
- </demo-item>
- <demo-item :label="t('自定义')">
- <cl-cascader
- v-model="form.cascader3"
- :options="options"
- :disabled="isDisabled"
- :text-separator="isSeparator ? ' / ' : ' - '"
- :height="isHeight ? 500 : 800"
- ></cl-cascader>
- <cl-list
- border
- :pt="{
- className: 'mt-3'
- }"
- >
- <cl-list-item :label="t('换个分隔符')">
- <cl-switch v-model="isSeparator"></cl-switch>
- </cl-list-item>
- <cl-list-item :label="t('列表高度小一点')">
- <cl-switch v-model="isHeight"></cl-switch>
- </cl-list-item>
- <cl-list-item :label="t('禁用')">
- <cl-switch v-model="isDisabled"></cl-switch>
- </cl-list-item>
- </cl-list>
- </demo-item>
- </view>
- </cl-page>
- </template>
- <script lang="ts" setup>
- import { reactive, ref } from "vue";
- import DemoItem from "../components/item.uvue";
- import { useCascader, type ClCascaderOption } from "@/uni_modules/cool-ui";
- import { t } from "@/locale";
- import pca from "@/data/pca.json";
- type Form = {
- cascader1: string[];
- cascader2: string[];
- cascader3: string[];
- };
- const form = reactive<Form>({
- cascader1: [],
- cascader2: [],
- cascader3: []
- });
- const isDisabled = ref(false);
- const isSeparator = ref(false);
- const isHeight = ref(false);
- const options = ref<ClCascaderOption[]>([
- {
- label: "电子产品",
- value: "1",
- children: [
- {
- label: "手机",
- value: "1-1",
- children: [
- {
- label: "苹果",
- value: "1-1-1",
- children: [
- {
- label: "iPhone 15 Pro Max",
- value: "1-1-1-1"
- },
- {
- label: "iPhone 15 Pro",
- value: "1-1-1-2"
- },
- {
- label: "iPhone 15",
- value: "1-1-1-3"
- },
- {
- label: "iPhone 14 Pro Max",
- value: "1-1-1-4"
- },
- {
- label: "iPhone 14",
- value: "1-1-1-5"
- }
- ]
- },
- {
- label: "华为",
- value: "1-1-2",
- children: [
- {
- label: "Mate 60 Pro+",
- value: "1-1-2-1"
- },
- {
- label: "Mate 60 Pro",
- value: "1-1-2-2"
- },
- {
- label: "Mate 60",
- value: "1-1-2-3"
- },
- {
- label: "P60 Pro",
- value: "1-1-2-4"
- },
- {
- label: "P60",
- value: "1-1-2-5"
- }
- ]
- },
- {
- label: "小米",
- value: "1-1-3",
- children: [
- {
- label: "小米14 Pro",
- value: "1-1-3-1"
- },
- {
- label: "小米14",
- value: "1-1-3-2"
- },
- {
- label: "Redmi K70 Pro",
- value: "1-1-3-3"
- },
- {
- label: "Redmi K70",
- value: "1-1-3-4"
- }
- ]
- }
- ]
- },
- {
- label: "电脑",
- value: "1-2",
- children: [
- {
- label: "笔记本",
- value: "1-2-1",
- children: [
- {
- label: "MacBook Pro 16",
- value: "1-2-1-1"
- },
- {
- label: "MacBook Pro 14",
- value: "1-2-1-2"
- },
- {
- label: "MacBook Air 15",
- value: "1-2-1-3"
- },
- {
- label: "ThinkPad X1",
- value: "1-2-1-4"
- },
- {
- label: "ROG 魔霸新锐",
- value: "1-2-1-5"
- },
- {
- label: "拯救者 Y9000P",
- value: "1-2-1-6"
- }
- ]
- },
- {
- label: "台式机",
- value: "1-2-2",
- children: [
- {
- label: "iMac 24寸",
- value: "1-2-2-1"
- },
- {
- label: "Mac Studio",
- value: "1-2-2-2"
- },
- {
- label: "Mac Pro",
- value: "1-2-2-3"
- },
- {
- label: "外星人",
- value: "1-2-2-4"
- },
- {
- label: "惠普暗影精灵",
- value: "1-2-2-5"
- }
- ]
- }
- ]
- },
- {
- label: "平板",
- value: "1-3",
- children: [
- {
- label: "iPad",
- value: "1-3-1",
- children: [
- {
- label: "iPad Pro 12.9",
- value: "1-3-1-1"
- },
- {
- label: "iPad Pro 11",
- value: "1-3-1-2"
- },
- {
- label: "iPad Air",
- value: "1-3-1-3"
- },
- {
- label: "iPad mini",
- value: "1-3-1-4"
- }
- ]
- },
- {
- label: "安卓平板",
- value: "1-3-2",
- children: [
- {
- label: "小米平板6 Pro",
- value: "1-3-2-1"
- },
- {
- label: "华为MatePad Pro",
- value: "1-3-2-2"
- },
- {
- label: "三星Galaxy Tab S9",
- value: "1-3-2-3"
- }
- ]
- }
- ]
- }
- ]
- },
- {
- label: "服装",
- value: "2",
- children: [
- {
- label: "男装",
- value: "2-1",
- children: [
- {
- label: "上衣",
- value: "2-1-1",
- children: [
- {
- label: "短袖T恤",
- value: "2-1-1-1"
- },
- {
- label: "长袖T恤",
- value: "2-1-1-2"
- },
- {
- label: "衬衫",
- value: "2-1-1-3"
- },
- {
- label: "卫衣",
- value: "2-1-1-4"
- },
- {
- label: "夹克",
- value: "2-1-1-5"
- },
- {
- label: "毛衣",
- value: "2-1-1-6"
- }
- ]
- },
- {
- label: "裤装",
- value: "2-1-2",
- children: [
- {
- label: "牛仔裤",
- value: "2-1-2-1"
- },
- {
- label: "休闲裤",
- value: "2-1-2-2"
- },
- {
- label: "运动裤",
- value: "2-1-2-3"
- },
- {
- label: "西裤",
- value: "2-1-2-4"
- },
- {
- label: "短裤",
- value: "2-1-2-5"
- }
- ]
- },
- {
- label: "外套",
- value: "2-1-3",
- children: [
- {
- label: "羽绒服",
- value: "2-1-3-1"
- },
- {
- label: "大衣",
- value: "2-1-3-2"
- },
- {
- label: "夹克",
- value: "2-1-3-3"
- },
- {
- label: "西装",
- value: "2-1-3-4"
- }
- ]
- }
- ]
- },
- {
- label: "女装",
- value: "2-2",
- children: [
- {
- label: "裙装",
- value: "2-2-1",
- children: [
- {
- label: "连衣裙",
- value: "2-2-1-1"
- },
- {
- label: "半身裙",
- value: "2-2-1-2"
- },
- {
- label: "A字裙",
- value: "2-2-1-3"
- },
- {
- label: "包臀裙",
- value: "2-2-1-4"
- },
- {
- label: "百褶裙",
- value: "2-2-1-5"
- }
- ]
- },
- {
- label: "上装",
- value: "2-2-2",
- children: [
- {
- label: "衬衫",
- value: "2-2-2-1"
- },
- {
- label: "T恤",
- value: "2-2-2-2"
- },
- {
- label: "毛衣",
- value: "2-2-2-3"
- },
- {
- label: "卫衣",
- value: "2-2-2-4"
- },
- {
- label: "雪纺衫",
- value: "2-2-2-5"
- }
- ]
- },
- {
- label: "外套",
- value: "2-2-3",
- children: [
- {
- label: "风衣",
- value: "2-2-3-1"
- },
- {
- label: "羽绒服",
- value: "2-2-3-2"
- },
- {
- label: "大衣",
- value: "2-2-3-3"
- },
- {
- label: "西装",
- value: "2-2-3-4"
- },
- {
- label: "皮衣",
- value: "2-2-3-5"
- }
- ]
- }
- ]
- }
- ]
- },
- {
- label: "食品",
- value: "3",
- children: [
- {
- label: "水果",
- value: "3-1",
- children: [
- {
- label: "苹果",
- value: "3-1-1"
- },
- {
- label: "香蕉",
- value: "3-1-2"
- },
- {
- label: "橘子",
- value: "3-1-3"
- }
- ]
- },
- {
- label: "蔬菜",
- value: "3-2",
- children: [
- {
- label: "西红柿",
- value: "3-2-1"
- },
- {
- label: "黄瓜",
- value: "3-2-2"
- },
- {
- label: "胡萝卜",
- value: "3-2-3"
- }
- ]
- }
- ]
- },
- {
- label: "饮料",
- value: "4",
- children: [
- {
- label: "果汁",
- value: "4-1",
- children: [
- {
- label: "苹果汁",
- value: "4-1-1"
- },
- {
- label: "橙汁",
- value: "4-1-2"
- },
- {
- label: "葡萄汁",
- value: "4-1-3"
- },
- {
- label: "西瓜汁",
- value: "4-1-4"
- }
- ]
- }
- ]
- }
- ]);
- const options2 = useCascader(pca);
- </script>
|