trike-datav/src/components/areaList.vue

121 lines
1.9 KiB
Vue
Raw Normal View History

2023-11-28 18:35:14 +08:00
<script setup>
2023-11-29 18:49:31 +08:00
import { defineProps, defineEmits, ref, nextTick, } from "vue"
2023-11-28 18:35:14 +08:00
import { useRouter } from 'vue-router'
const router = useRouter()
2023-11-29 18:49:31 +08:00
const emit = defineEmits(['offAreaList']);
const choseArea = ref(false);
2023-11-28 18:35:14 +08:00
const list = ref([
{
2023-11-29 18:49:31 +08:00
name: '泸县',
pinyin: 'luxian',
2023-11-28 18:35:14 +08:00
},
{
2023-11-29 18:49:31 +08:00
name: '江阳区',
pinyin: 'jiangyang',
2023-11-28 18:35:14 +08:00
},
{
2023-11-29 18:49:31 +08:00
name: '龙马潭区',
pinyin: 'longma',
2023-11-28 18:35:14 +08:00
},
{
2023-11-29 18:49:31 +08:00
name: '纳溪区',
pinyin: 'naxi',
2023-11-28 18:35:14 +08:00
},
{
2023-11-29 18:49:31 +08:00
name: '合江县',
pinyin: 'hejiang',
2023-11-28 18:35:14 +08:00
},
{
2023-11-29 18:49:31 +08:00
name: '叙永县',
pinyin: 'xuyong',
2023-11-28 18:35:14 +08:00
},
{
2023-11-29 18:49:31 +08:00
name: '古蔺县',
pinyin: 'gulin',
2023-11-28 18:35:14 +08:00
},
])
// 选镇
const choseTownFn = (item) => {
emit('offAreaList', item);
}
2023-11-29 18:49:31 +08:00
const open = () => {
choseArea.value = true;
}
const close = () => {
choseArea.value = false;
}
const show = () => {
choseArea.value = !choseArea.value;
}
defineExpose({
open, close, show
})
2023-11-28 18:35:14 +08:00
</script>
<template>
<transition name="fade">
2023-11-29 18:49:31 +08:00
<div class="address" v-show="choseArea == true">
2023-11-28 18:35:14 +08:00
<div
class="address-li"
@click="choseTownFn(item)"
v-for="(item, index) in list"
:key="index"
>
{{ item.name }}
</div>
</div>
</transition>
</template>
<style lang="scss" scoped>
.address {
left: 1vw;
top: 18px;
position: absolute;
width: 10vw;
height: 18vh;
background-color: #001e32;
color: #c7dbe3;
z-index: 9999;
overflow-y: auto;
box-sizing: border-box;
padding: 5px;
.address-li {
padding: 2px 5px;
cursor: pointer;
border-bottom: 0.1px solid #0e293c;
}
}
.address::-webkit-scrollbar {
width: 10px;
background-color: #153041;
}
.address::-webkit-scrollbar-track {
background-color: #153041;
}
::-webkit-scrollbar-thumb {
background-color: #4ab9d0;
border-radius: 5px;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.5s;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
</style>