当前位置:网站首页>自定义封装下拉组件
自定义封装下拉组件
2022-06-26 12:37:00 【a٩(๑ʊ始于ʃʃʃ繁华ʊ๑)۶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: {
// 下拉列表数据 data: {
type: Array, default: [], }, selectedName: {
type: String, default: "", }, }, watch: {
// 默认选中名称 selectedName(val) {
this.name = val; }, }, data() {
return {
name: this.selectedName, show: false, }; }, methods: {
// 展开列表 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>
子组件
<Select :selectedName="浙江省" :data="placeData" ></Select>
<Select :selectedName="timeData[0]" :data="timeData" style="position: absolute; top: 0px; right: 130px" ></Select>
data(){
return{
timeData: ["2022", "2021", "2020"],
placeData: [
"浙江省",
"杭州市",
"宁波市",
"温州市",
"湖州市",
"嘉兴市",
"绍兴市",
"金华市",
"衢州市",
"舟山市",
"台州市",
"丽水市",
],
}
}
边栏推荐
- Spark-day01- get started quickly
- Vscode solves the problem of Chinese garbled code
- 班主任让开股票账户,在挖财理财开户安全吗?
- [esp32-C3][RT-THREAD] 基于ESP32C3运行RT-THREAD bsp最小系统
- NoSQL mongodb - 02 mongodb server installation, mongodb shell, basic concepts and visualization tools
- BigInt:处理大数字(任意长度的整数)
- PHP generate order number
- solo 博客系统的 rss 渲染失败
- 小程序中控件里面的内容较多,让其支持滚动的良好方案
- Scala-day06- pattern matching - Generic
猜你喜欢
![[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure](/img/d2/a6cbb0abe9e04c412d1f6021430528.png)
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure

记一次phpcms9.6.3漏洞利用getshell到内网域控

Tiger DAO VC产品正式上线,Seektiger生态的有力补充

Build Pikachu shooting range and introduction

计组实践实验9——使用CMStudio设计基于分段模型机微程序指令(2)

小程序中控件里面的内容较多,让其支持滚动的良好方案

Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology

Less than 40 lines of code to create a blocprovider

BigInt:处理大数字(任意长度的整数)

NoSQL mongodb - 01 introduction to NoSQL and mongodb
随机推荐
KITTI Tracking dataset whose format is letf_top_right_bottom to JDE normalied xc_yc_w_h
JS how to judge when data contains integer and floating-point types. Floating-point decimals retain two digits after the decimal point
[esp32-C3][RT-THREAD] 基于ESP32C3运行RT-THREAD bsp最小系统
power designer - 自定义注释按钮
程序员必备,一款让你提高工作效率N倍的神器uTools
记一次phpcms9.6.3漏洞利用getshell到内网域控
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
PHP get directory size
Summary of some application research cases of UAV Remote Sensing in forest monitoring
CG bone animation
sqlalchemy event listen Automatic generate CRUD excel
Build Pikachu shooting range and introduction
Stream流学习记录
imagecopymerge
MySQL optimization - index (what is an index?)
PHP generate order number
Realize microservice load balancing (ribbon)
7-1 数的范围
[BSidesCF 2019]Kookie 1
Redis learning - 04 persistence