tiny-vue/examples/sites/demos/pc/app/select/slot-default.vue

96 lines
2.7 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<p>场景1带标签和提示信息</p>
<br />
<tiny-select v-model="value1" popper-class="slot-default">
<template v-for="item in options1">
<tiny-tooltip v-if="item.tip" :content="item.tip" placement="right" effect="light" :key="item.value">
<tiny-option :label="item.label" :value="item.value">
<span class="left">{{ item.label }}</span>
<tiny-tag v-if="item.tag" type="danger" effect="light" size="small">{{ item.tag }}</tiny-tag>
</tiny-option>
</tiny-tooltip>
<tiny-option v-if="!item.tip" :key="item.value" :label="item.label" :value="item.value">
<span class="left">{{ item.label }}</span>
<tiny-tag v-if="item.tag" type="danger" effect="light" size="small">{{ item.tag }}</tiny-tag>
</tiny-option>
</template>
</tiny-select>
<br /><br />
<p>场景2选项双行</p>
<br />
<tiny-select v-model="value2" popper-class="double-row">
<tiny-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value">
<div>
<p>
{{ item.label }}
</p>
<p>{{ item.desc }}</p>
</div>
</tiny-option>
</tiny-select>
</div>
</template>
<script>
import { Select, Option, Tag, Tooltip } from '@opentiny/vue'
export default {
components: {
TinySelect: Select,
TinyOption: Option,
TinyTag: Tag,
TinyTooltip: Tooltip
},
data() {
return {
options1: [
{ value: '选项1', label: '北京', tag: 'New', tip: '自定义提示' },
{ value: '选项2', label: '上海' },
{ value: '选项3', label: '天津' },
{ value: '选项4', label: '重庆' },
{ value: '选项5', label: '深圳' }
],
options2: [
{ value: '选项1', label: '子网1 192.168.0.1/24', desc: '可用 IP 数 250' },
{ value: '选项2', label: '子网2 192.168.0.1/24', desc: '可用 IP 数 250' },
{ value: '选项3', label: '子网3 192.168.0.1/24', desc: '可用 IP 数 250' },
{ value: '选项4', label: '子网4 192.168.0.1/24', desc: '可用 IP 数 250' },
{ value: '选项5', label: '子网5 192.168.0.1/24', desc: '可用 IP 数 250' }
],
value1: '选项1',
value2: '选项1'
}
}
}
</script>
<style lang="less" scoped>
.tiny-select {
width: 280px;
}
.tiny-option {
.left {
margin-right: 8px;
}
p {
height: 18px;
line-height: 18px;
margin: 6px;
}
}
</style>
<style lang="less">
.double-row {
&.tiny-select-dropdown .tiny-select-dropdown__wrap {
max-height: 224px;
.tiny-option {
height: 54px;
}
}
}
</style>