当前位置:网站首页>Custom encapsulation drop-down component
Custom encapsulation drop-down component
2022-06-26 13:16:00 【a ٩ (๑ ʊ Begin with ʃʃʃ bustling ʊ ๑) ۶ a】
<template>
<div class="select-wrap">
<div class="select" @click="selectShow">
{
{ name }} ▼
<div class="select-show" v-show="show">
<div class="select-item" v-for="(item, index) in data" :key="index" @click="selectItem(index)" >
{
{ item }}
</div>
</div>
</div>
</div>
</template>
<script> export default {
props: {
// Drop down list data data: {
type: Array, default: [], }, selectedName: {
type: String, default: "", }, }, watch: {
// Default selected name selectedName(val) {
this.name = val; }, }, data() {
return {
name: this.selectedName, show: false, }; }, methods: {
// Expand the list selectShow() {
this.show = !this.show; }, selectItem(index) {
this.name = this.data[index]; }, }, }; </script>
<style scoped> .select {
cursor: pointer; position: absolute; top: 50px; right: 50px; width: 110px; height: 31px; background: #2a3c5a; display: flex; justify-content: center; align-items: center; color: #fff; z-index: 1000; } .select-show {
position: absolute; background: #2a3c5a; display: flex; justify-content: center; align-items: center; color: #fff; top: 34px; left: 0; display: flex; flex-direction: column; } .select-item {
right: 50px; width: 110px; height: 31px; display: flex; align-items: center; justify-content: center; border: 1px solid #4a73a6; } </style>
Child components
<Select :selectedName=" Zhejiang Province " :data="placeData" ></Select>
<Select :selectedName="timeData[0]" :data="timeData" style="position: absolute; top: 0px; right: 130px" ></Select>
data(){
return{
timeData: ["2022", "2021", "2020"],
placeData: [
" Zhejiang Province ",
" hangzhou ",
" Ningbo City ",
" Wenzhou City ",
" Huzhou City ",
" Jiaxing City ",
" Shaoxing City ",
" Jinhua City ",
" Quzhou City ",
" Zhoushan City ",
" Taizhou City ",
" Lishui City ",
],
}
}
边栏推荐
- P5733 [deep foundation 6. example 1] automatic correction
- Fire warning is completed within 10 seconds, and Baidu AI Cloud helps Kunming Guandu build a new benchmark of smart city
- Electron official docs series: Testing And Debugging
- I have a good word to say, and I admire myself
- Deep parsing MySQL binlog
- G - Cow Bowling
- 享元模式(Flyweight)
- Design of four kinds of linear phase FIR filters -- complete set of Matlab source code
- 倍福PLC基于CX5130实现数据的断电保持
- mariadb学习笔记
猜你喜欢
Processing random generation line animation
倍福PLC通过程序获取系统时间、本地时间、当前时区以及系统时间时区转换
Decorator
倍福PLC基于CX5130实现数据的断电保持
mysql讲解(一)
Arcpy -- use of insertlayer() function: adding layers to map documents
System tasks (display / print class) in Verilog - $display, $write, $strobe, $monitor
MariaDB study notes
享元模式(Flyweight)
装饰器(Decorator)
随机推荐
scrapy——爬取漫画自定义存储路径下载到本地
Mode pont
C language: Exercise 2
橋接模式(Bridge)
Beifu PLC realizes zero point power-off hold of absolute value encoder -- use of bias
Word document export (using fixed template)
Processing function translate (mousex, mousey) learning
B - Bridging signals
Angle de calcul POSTGIS
Electron official docs series: Examples
倍福EtherCAT Xml描述文件更新和下载
Typescript
Explain C language 10 in detail (C language series)
Oplg: new generation cloud native observable best practices
UVa11582 [快速幂]Colossal Fibonacci Numbers!
桥接模式(Bridge)
C语言:练习题二
sql 将数据表b字段值赋值到数据表a中某一列
Explain C language 11 in detail (C language series)
To solve the difficulties of small and medium-sized enterprises, Baidu AI Cloud makes an example