国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

vue3實(shí)現(xiàn)自定義select下拉框內(nèi)容之城市區(qū)域篇

這篇具有很好參考價(jià)值的文章主要介紹了vue3實(shí)現(xiàn)自定義select下拉框內(nèi)容之城市區(qū)域篇。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

歡迎點(diǎn)擊領(lǐng)取 -《前端開發(fā)面試題進(jìn)階秘籍》:前端登頂之巔-最全面的前端知識(shí)點(diǎn)梳理總結(jié)

需求分析:
1、實(shí)現(xiàn)一個(gè)區(qū)域下拉選項(xiàng)與現(xiàn)有ui組件庫不同,支持多選、單選需求
2、支持選中區(qū)域后-全選中當(dāng)前區(qū)域下的所有城市信息
3、只能選中當(dāng)前一個(gè)區(qū)域的內(nèi)的城市其余城市禁用

擴(kuò)展思路:
1、封裝公共組件或者封裝在組件庫內(nèi)
2、出入?yún)⑾嚓P(guān)api透明好理解
3、支持單選或者多選,支持只選擇當(dāng)前區(qū)域下的城市或者全面區(qū)域下的城市
4、在原有的element plus下進(jìn)行擴(kuò)展延伸滿足需求
5、缺陷:未做maxLength-標(biāo)簽最大展示的api;這個(gè)按需自己修改一下就行

1、第一種模式:顯示區(qū)域信息
vue3實(shí)現(xiàn)自定義select下拉框內(nèi)容之城市區(qū)域篇,vue3,element plus,vite,狀態(tài)模式
2、第二種模式:只展示城市內(nèi)容
vue3實(shí)現(xiàn)自定義select下拉框內(nèi)容之城市區(qū)域篇,vue3,element plus,vite,狀態(tài)模式

1、相關(guān)開發(fā)代碼篇

創(chuàng)建文件:custom-select.vue文件;復(fù)制copy當(dāng)下代碼;
使用方式:
1、外部入?yún)⒗绯鞘校?code>dataSource=[{ label: 華北,value: '華東', children: [{ label: '山東',value: 'shandong'}]],樹形結(jié)構(gòu)
2、標(biāo)簽引用:<custom-select :disabled="true" :multilevel="true" height="32" v-model="checkGroup" :dataSource="cityList"></custom-select>
3、相關(guān)api說明文檔在文章底部文章來源地址http://www.zghlxwxcb.cn/news/detail-646050.html

<template>
  <div
    tabindex="1"
    ref="customSelectRef"
    @click="handleClickDiv"
    @mouseenter="handelMouseEnter"
    @mouseleave="handleMouseLeave"
    :style="{ width: modelLabel && modelValue?.length ? '166px' : '100px', height: (height + 'px') || '25px' }"
    :class="['custom-select_contaniner-i', isShowDropdown && 'custom-select_background']"
  >
    <div>
      <span v-if="modelLabel" class="custom-tag">
        <span>{{ modelLabel }}</span>
        <i
          class="custom_tag_delete"
          @mouseenter="handelIconMouseEnter"
          @mouseleave="handleIconMouseLeave"
          @click.stop="handleDeleteIcon"
        >
          <svg
            v-if="!ishShowIconDeleteText"
            t="1678090923023"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="6709"
            width="11"
            height="11"
          >
            <path
              d="M263.802377 224.219482a7.964444 7.964444 0 0 1 11.263425 0l236.934198 236.934198 236.934198-236.934198a7.964444 7.964444 0 0 1 11.263425 0l39.582895 39.582895a7.964444 7.964444 0 0 1 0 11.263425l-236.934198 236.934198 236.934198 236.934198a7.964444 7.964444 0 0 1 0 11.263425l-39.582895 39.582895a7.964444 7.964444 0 0 1-11.263425 0l-236.934198-236.934198-236.934198 236.934198a7.964444 7.964444 0 0 1-11.263425 0l-39.582895-39.582895a7.964444 7.964444 0 0 1 0-11.263425l236.934198-236.934198-236.934198-236.934198a7.964444 7.964444 0 0 1 0-11.263425l39.582895-39.582895z"
              fill="#8a8a8a"
              p-id="6710"
            />
          </svg>
          <svg
            v-else
            t="1678091410677"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="6936"
            width="22"
            height="22"
          >
            <path
              d="M479.072 512l-98.72-98.72c-9.152-9.152-9.088-23.84 0-32.928 9.152-9.152 23.84-9.088 32.928 0l98.72 98.72 98.72-98.72c9.152-9.152 23.84-9.088 32.928 0 9.152 9.152 9.088 23.84 0 32.928l-98.72 98.72 98.72 98.72c9.152 9.152 9.088 23.84 0 32.928-9.152 9.152-23.84 9.088-32.928 0l-98.72-98.72-98.72 98.72c-9.152 9.152-23.84 9.088-32.928 0-9.152-9.152-9.088-23.84 0-32.928l98.72-98.72zM512 837.824c179.936 0 325.824-145.888 325.824-325.824s-145.888-325.824-325.824-325.824c-179.936 0-325.824 145.888-325.824 325.824s145.888 325.824 325.824 325.824z"
              fill="#B7B8B9"
              p-id="6937"
            />
          </svg>
        </i>
      </span>
      <span v-if="modelLabel && modelValue?.length > 1" class="custom-tag">+ {{ modelValue.length - 1 }}</span>
      <span v-if="!modelLabel" class="cus_placeholder">{{ placeholder }}</span>
    </div>
    <i class="arrow-top-icon" v-if="!isShowIconRemove || !modelLabel" :class="[!isShowDropdown && 'arrow-top-icon-active']">
      <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
        <path
          fill="currentColor"
          d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"
        />
      </svg>
    </i>
    <i class="remove-icon" v-if="isShowIconRemove && modelLabel" @click.stop="handleRemove">
      <svg
        t="1678084213981"
        class="icon"
        viewBox="0 0 1024 1024"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
        p-id="4480"
        width="11"
        height="11"
      >
        <path
          d="M512 32c265.097 0 480 214.903 480 480S777.097 992 512 992 32 777.097 32 512 246.903 32 512 32z m0 64C282.25 96 96 282.25 96 512s186.25 416 416 416 416-186.25 416-416S741.75 96 512 96z m169.706 246.294c12.496 12.497 12.496 32.758 0 45.255L557.256 512l124.45 124.452c12.496 12.497 12.496 32.758 0 45.255-12.497 12.496-32.758 12.496-45.255 0L512 557.254 387.549 681.706c-12.497 12.496-32.758 12.496-45.255 0-12.496-12.497-12.496-32.758 0-45.255l124.452-124.452-124.452-124.45c-12.496-12.497-12.496-32.758 0-45.255 12.497-12.496 32.758-12.496 45.255 0l124.452 124.45 124.45-124.45c12.497-12.496 32.758-12.496 45.255 0z"
          fill="#8a8a8a"
          p-id="4481"
        />
      </svg>
    </i>
  </div>
  <transition>
    <div
      v-if="isShowDropdown"
      ref="cusSelectDropdown"
      class="cus_select_background"
      :style="{ minWidth: popperOffestWidth + 'px', zIndex: 99999 }"
    >
      <div v-if="multilevel" style="padding: 5px 20px;">
        <div :key="key" v-for="(opt, key) in cusDataListChecked" class="multilevel_box">
          <el-checkbox
            style="width: 60px;"
            v-model="opt.checkAll"
            @change="handleCheckAllChange($event, opt)"
            :indeterminate="opt.isIndeterminate"
            :disabled="disabled && checkList.length ? !opt.checkList.length : false"
            >
            {{ opt.label }}
          </el-checkbox>
          <el-checkbox-group 
            v-model="opt.checkList"
            v-if="opt.children"
            @change="handleCheckedCitiesChange($event, opt)"
            style="display: inline-block; padding-left: 20px" 
          >
              <el-checkbox 
                :label="item.value" 
                style="width: 60px"
                :key="index + Math.random()" 
                v-for="(item, index) in opt.children" 
                :disabled="disabled && checkList.length ? !opt.checkList.length : false"
                >
                {{ item.label }}
              </el-checkbox>
          </el-checkbox-group>
        </div>
      </div>
      <div class="cus_select_contaniner" v-else>
        <div class="cus_select_left">中國</div>
        <div class="cus_select_right">
          <el-checkbox-group 
            v-model="checkList" 
            @change="handelCheckGroup"
            style="display: inline-block; padding-left: 20px" 
          >
            <el-checkbox 
              :key="index" 
              :label="item.value" 
              style="width: 60px"
              v-for="(item, index) in dataSource" 
            >
              {{ item.label }}
            </el-checkbox>
          </el-checkbox-group>
        </div>
      </div>
      <span class="el-popper__arrow" data-popper-arrow="" style="position: absolute; left: 140px;"></span>
    </div>
  </transition>
</template>
<script setup lang="ts">
import { createPopper } from '@popperjs/core'
import { ref, onMounted, nextTick, watch, onUnmounted, toRaw, onBeforeMount, computed } from 'vue'

const props = withDefaults(
  defineProps<{
    height?: string | number
    dataSource: any
    modelValue?: any
    placeholder?: string
    multilevel?: boolean
    disabled?: boolean
  }>(),
  {
    height: 25,
    disabled: false,
    multilevel: false,
    dataSource: [],
    modelValue: [],
    placeholder: '請(qǐng)選擇'
  }
)

const emit = defineEmits(['update:modelValue'])

const customSelectRef = ref()

const cusSelectDropdown = ref()

const cusDataListChecked = ref<any[]>([])

const checkList = ref<string[]>([])

const popperOffestWidth = ref<number>(0)

const isShowDropdown = ref<boolean>(false)

const modelLabel = ref<string>('')

const isShowIconRemove = ref<boolean>(false)

const ishShowIconDeleteText = ref<boolean>(false)

const handleClickDiv = () => {
  isShowDropdown.value = !isShowDropdown.value
}

const handelCheckGroup = (value) => {
  const obj = props.dataSource.filter((item) => item.value === value[0])[0]
  modelLabel.value = obj?.label
  emit('update:modelValue', value)
}

const handelMouseEnter = () => {
  isShowIconRemove.value = true
}

const handleMouseLeave = () => {
  isShowIconRemove.value = false
}

const handleRemove = () => {
  modelLabel.value = ''
  checkList.value = []
  if (isShowDropdown.value) {
    isShowDropdown.value = false
  }
  if (props.multilevel) {
    cusDataListChecked.value = addCheckProperties(props.dataSource)
  }
  emit('update:modelValue', [])
}

const handleDeleteIcon = () => {
  isShowDropdown.value = false
  checkList.value.splice(0, 1)
  if (props.multilevel) return cusDataListChecked.value = findTreeChecked(cusDataListChecked.value)
  const info = toRaw(checkList.value)[0]
  const obj = props.dataSource.filter((item) => item.value === info)[0]
  modelLabel.value = obj?.label || ''
}

const handelIconMouseEnter = () => {
  ishShowIconDeleteText.value = true
}

const handleIconMouseLeave = () => {
  ishShowIconDeleteText.value = false
}

// 點(diǎn)擊某個(gè)DOM元素之外的方法
const handlerDocClick = (event) => {
  const isSelf = customSelectRef.value?.contains(event.target) 
  || cusSelectDropdown.value?.contains(event.target)
  if (!isSelf) {
    isShowDropdown.value = false
  }
}

/**
 * 展示區(qū)域省份的邏輯
 * */ 
const handleCheckAllChange = (bool: any, option) => {
  const allCity = option.children ? option.children.map(item => item.value) : [option.value]
  bool ? option.checkList = allCity : option.checkList = []
  option.isIndeterminate = false
  checkList.value = option.checkList
  const newLabelArr = option.children 
  ? option.children.filter(item => checkList.value.includes(item.value)) 
  : checkList.value?.length ? [{ label: '默認(rèn)' }] : []
  modelLabel.value = newLabelArr?.[0]?.label || ''
  emit('update:modelValue', checkList.value)
}

const handleCheckedCitiesChange = (value: any[], option) => {
  const checkedCount = value.length
  const allCity = option.children ? option.children.map(item => item.value) : [option.value]
  option.checkAll = checkedCount === allCity.length
  option.isIndeterminate = checkedCount > 0 && checkedCount < allCity.length
  checkList.value = option.checkList
  const newLabelArr = option.children 
  ? option.children.filter(item => checkList.value.includes(item.value)) 
  : checkList.value?.length ? [{ label: '默認(rèn)' }] : []
  modelLabel.value = newLabelArr?.[0]?.label || ''
  emit('update:modelValue', checkList.value)
}

const addCheckProperties = (treeData) => {
  let result = []
  result = JSON.parse(JSON.stringify(treeData))
  result.forEach(node => {
    const child = node.children;
    node.checkAll = false;
    node.isIndeterminate = false;
    node.checkList = [];
    if (child && child.length > 0) {
      addCheckProperties(child);
    }
  });
  return result
}

const findTreeChecked = (treeData) => {
  let newLabel
  const val = toRaw(checkList.value)
  const defaultBool = val.some(item => item.includes('default'))
  treeData.forEach(node => {
    if (node.children?.length) {
      const child = node.children;
      const bool = child.some(opt => val.includes(opt.value))
      !newLabel ? newLabel = child.filter(item => val.includes(item.value))[0] : void null
      if (bool) {
        node.checkAll = val.length === child?.length;
        node.isIndeterminate = val.length > 0 && val.length < child?.length;
        node.checkList = val;
      } else {
        node.isIndeterminate = false
      }
    }
  })
  treeData[0].isIndeterminate = false;
  treeData[0].checkAll = defaultBool ? true : false;
  treeData[0].checkList = defaultBool ? ['default'] : [];
  modelLabel.value = defaultBool ? '默認(rèn)' : newLabel?.label || ''
  return treeData
}

watch(
  [customSelectRef, cusSelectDropdown],
  () => {
    if (customSelectRef.value && cusSelectDropdown.value) {
      createPopper(customSelectRef.value, cusSelectDropdown.value, {
        placement: 'bottom',
        modifiers: [
          {
            name: 'offset',
            options: {
              offset: [80, 8]
            }
          }
        ]
      })
    }
  },
  {
    deep: true,
    immediate: true
  }
)

watch(
  props.modelValue,
  (newval) => {
    if (!newval || !newval.length) return
    checkList.value = props.modelValue
    if (props.multilevel) return
    const obj = props.dataSource.filter((item) => item.value === newval[0])[0]
    modelLabel.value = obj?.label
  },
  {
    deep: true,
    immediate: true
  }
)

onBeforeMount(() => {
  if (props.multilevel) {
    cusDataListChecked.value = addCheckProperties(props.dataSource)
  }
})

onMounted(async () => {
  await nextTick()
  popperOffestWidth.value = customSelectRef.value.offsetWidth
  document.addEventListener('click', handlerDocClick, true)
  if (props.multilevel && props.modelValue.length) { 
    cusDataListChecked.value = findTreeChecked(cusDataListChecked.value)
  }
})

onUnmounted(() => {
  document.removeEventListener('click', handlerDocClick, true)
})
</script>

<script lang="ts">
export default { name: 'CustomSelect' }
</script>

<style lang="scss" scoped>
.v-enter-active,
.v-leave-active {
  transition: opacity 0.5s ease;
}

.v-enter-from,
.v-leave-to {
  opacity: 0;
}

.custom-select_contaniner-i {
  width: 100%;
  height: 25px;
  padding: 7px 9px;
  padding-left: 5px;
  border-radius: 4px;
  line-height: 1;
  cursor: pointer;
  position: relative;
  user-select: none;
  word-wrap: break-word;
  word-break: break-all;
  font-size: 13px;
  flex-grow: 1;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  justify-content: space-between;
  color: var(--el-input-text-color, var(--el-text-color-regular));
  background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
  box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
}

.custom-tag {
  color: var(--el-color-info);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 18px;
  padding: 0 9px;
  line-height: 1;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 12px;
  background-color: var(--el-fill-color);
}

.custom_tag_delete {
  width: 18px;
  margin-left: 5px;
  font-size: 0px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: var(--el-color-info);
}

.custom-tag:first-child {
  margin-right: 6px;
  padding-right: 4px;
}

.arrow-top-icon {
  width: 14px;
  transform: rotateX(-180deg);
  color: var(--el-text-color-placeholder);
}

.remove-icon {
  margin-top: 2px;
  color: var(--el-text-color-placeholder);
}

.arrow-top-icon-active {
  transform: rotateX(0deg);
}

.custom-select:hover {
  box-shadow: 0 0 0 1px var(--el-border-color-hover) inset;
}

.custom-select:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--el-color-primary) inset;
}

.custom-select_background {
  box-shadow: 0 0 0 1px var(--el-color-primary) inset;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
  background-color: transparent;
}

/*滾動(dòng)條的軌道*/
::-webkit-scrollbar-track {
  background-color: transparent;
}

/*滾動(dòng)條的滑塊按鈕*/
::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 0 2px rgba(#000000, 0.04);
}

/*滾動(dòng)條的上下兩端的按鈕*/
::-webkit-scrollbar-button {
  height: 0;
  background-color: transparent;
}

.cus_select_contaniner {
  padding: 5px 10px;
  display: flex;
}

.cus_select_left {
  width: 60px;
  margin-top: 5px;
}

.cus_select_right {
  flex: 1;
  width: 480px;
}

.cus_select_background {
  min-height: 200px;
  box-sizing: border-box;
  border-radius: 4px;
  font-size: var(--el-font-size-base);
  color: var(--el-text-color-regular);
  background: var(--el-bg-color-overlay);
  border: 1px solid var(--el-border-color-light);
  .multilevel_box {
    display: flex; 
    padding: 5px; 
    border-bottom: 1px solid #e4e7ed;
  }
  .multilevel_box:last-child {
    border-bottom: none;
  }
}

.cus_placeholder {
  color: var(--el-text-color-placeholder);
}

.el-popper__arrow {
  top: -5px;
}

.el-popper__arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  z-index: -1;
}

.el-popper__arrow::before {
  border: 1px solid var(--el-border-color-light);
  background: var(--el-bg-color-overlay);
  right: 0;
  border-bottom-color: transparent!important;
  border-right-color: transparent!important;
}
</style>
2、組件-相關(guān)api說明
參數(shù) 說明 類型 默認(rèn)值 必填項(xiàng)
height 輸入框的高度 String/Number 25
dataSource [{}]-label,value;樹形結(jié)構(gòu) Array[] []
modelValue 當(dāng)前選中項(xiàng)內(nèi)容 Array []
placeholder 輸入框內(nèi)容 String 請(qǐng)輸入
multilevel 是否開啟跨層級(jí)模式 Boolean false
disabled 是否開啟跨層級(jí)禁用 Boolean false

到了這里,關(guān)于vue3實(shí)現(xiàn)自定義select下拉框內(nèi)容之城市區(qū)域篇的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Vue實(shí)現(xiàn)select下拉框二級(jí)聯(lián)動(dòng)數(shù)據(jù)后臺(tái)獲取

    Vue實(shí)現(xiàn)select下拉框二級(jí)聯(lián)動(dòng)數(shù)據(jù)后臺(tái)獲取

    一、二級(jí)聯(lián)動(dòng)在vue中實(shí)現(xiàn)selected的二級(jí)聯(lián)動(dòng)取其實(shí)很簡單,可以使用select下拉框的表單改變事件。 ?@change在表單內(nèi)容發(fā)生改變時(shí)出發(fā)方法。然后在下面的methods中聲明方法,通過this.form.ks獲取到當(dāng)前下拉框的數(shù)據(jù)。 ?然后調(diào)用后兩級(jí)訪問數(shù)據(jù)庫的方法,獲取到聯(lián)動(dòng)的數(shù)據(jù),添加

    2024年02月16日
    瀏覽(19)
  • vue+el-select下拉實(shí)現(xiàn):全選、反選、清空功能

    vue+el-select下拉實(shí)現(xiàn):全選、反選、清空功能

    問題描述: el-select下拉框要求實(shí)現(xiàn)全選功能。具體功能包括: 當(dāng)選擇【全選】時(shí),所有選項(xiàng)全部被勾選; 當(dāng)選擇【反選】時(shí),已選擇選項(xiàng)變?yōu)槲催x擇選項(xiàng),未選項(xiàng)變?yōu)橐堰x項(xiàng) 當(dāng)選擇【清空】時(shí),所有選項(xiàng)變?yōu)槲催x 如下圖: 1、給el-select增加【全選】【清空】【反選】按鈕

    2024年02月10日
    瀏覽(95)
  • Vue+EleMentUI實(shí)現(xiàn)el-table-colum表格select下拉框可編輯

    Vue+EleMentUI實(shí)現(xiàn)el-table-colum表格select下拉框可編輯

    在進(jìn)行采購入庫的過程中,有必要對(duì)表格中的一行進(jìn)行快速編輯保存,節(jié)省時(shí)間,提高工作效率!,而不是每次編輯都要彈窗才可編輯 源碼:https://gitee.com/charlinchenlin/store-pos 控制是否顯示select下拉框 如果showInput的值與當(dāng)前的inboundId相同,則顯示下拉選項(xiàng),否則顯示數(shù)據(jù)信息

    2024年02月01日
    瀏覽(26)
  • UVeiw 組件的使用(更多自定義案例和解決方案),Vue3 +ts 版本 #Selected組件 #Vue 3 # Ts
  • 如何vue使用ant design Vue中的select組件實(shí)現(xiàn)下拉分頁加載數(shù)據(jù),并解決存在的一個(gè)問題。

    如何vue使用ant design Vue中的select組件實(shí)現(xiàn)下拉分頁加載數(shù)據(jù),并解決存在的一個(gè)問題。

    ? ? 需求:拉下菜單中數(shù)據(jù)過多,200條以上,就會(huì)導(dǎo)致select組件卡死。所以需要使用滑動(dòng)到底部使其分頁加載 ? ? 可以借助 onPopupScroll 事件來監(jiān)聽下拉菜單的滾動(dòng)事件,并判斷當(dāng)前是否已經(jīng)到達(dá)了下拉菜單底部。具體可以通過以下步驟實(shí)現(xiàn): ? ? 1、在組件中綁定?@popupScro

    2023年04月20日
    瀏覽(38)
  • Vue 3 + Element UI Plus 實(shí)現(xiàn) Select 下拉框的虛擬滾動(dòng)效果詳解與代碼示例

    在 Vue 3 項(xiàng)目中,當(dāng)下拉框中的選項(xiàng)過多時(shí),使用虛擬滾動(dòng)可以提升性能和用戶體驗(yàn)。本文將介紹如何使用 Vue 3 和 Element UI Plus(el-select-plus)組件實(shí)現(xiàn) Select 下拉框的虛擬滾動(dòng)效果,并提供詳細(xì)的代碼示例。 首先,確保你已經(jīng)安裝了 Element UI Plus,它是 Element UI 的擴(kuò)展版本,支

    2024年02月08日
    瀏覽(37)
  • Vue + element ui 實(shí)現(xiàn)后臺(tái)數(shù)據(jù)渲染到下拉框選項(xiàng)中,同時(shí)將input框與下拉框聯(lián)動(dòng),select選定之后,input顯示對(duì)應(yīng)的值

    Vue + element ui 實(shí)現(xiàn)后臺(tái)數(shù)據(jù)渲染到下拉框選項(xiàng)中,同時(shí)將input框與下拉框聯(lián)動(dòng),select選定之后,input顯示對(duì)應(yīng)的值

    實(shí)現(xiàn)過程: 使用element 的select以及input輸入框 在data中定義一個(gè)數(shù)組用于接收后臺(tái)請(qǐng)求的數(shù)據(jù) method中定義一個(gè)方法,用于請(qǐng)求數(shù)據(jù) 在created中實(shí)現(xiàn)顯示: listMidMapping為封裝好的get請(qǐng)求 至此實(shí)現(xiàn)后臺(tái)數(shù)據(jù)渲染到下拉框選項(xiàng)中,效果圖: 以上借鑒于: (21條消息) Vue + element 實(shí)現(xiàn)動(dòng)

    2024年02月08日
    瀏覽(61)
  • vue3實(shí)現(xiàn)區(qū)域打印功能(vue3-print-nb)

    場景 大多數(shù)后臺(tái)系統(tǒng)中都存在打印的需求,在有打印需求時(shí),對(duì)前端來說當(dāng)然是直接打印頁面更容易,那么本篇文章就是在vue3中,使用vue3-print-nb插件來區(qū)域打印,實(shí)現(xiàn)指哪打哪! 一.安裝vue3-print-nb 二.在main.ts中引入 三.HTML 四.參數(shù)配置 推薦文章 Print.js實(shí)現(xiàn)打印pdf,HTML,圖片

    2024年02月12日
    瀏覽(13)
  • Vue3 實(shí)現(xiàn)下拉選擇框多選的功能實(shí)現(xiàn)

    Vue3 實(shí)現(xiàn)下拉選擇框多選的功能實(shí)現(xiàn)

    項(xiàng)目采用vue3+elmentui-plus +ts 搭建成的。用戶界面設(shè)計(jì)上需要一個(gè)帶全選的下拉選擇框。而element plus 官網(wǎng) 提供的下拉多選框是 這種形式是沒有全選按鈕的,并且樣式也不符合想像中的全選的操作。故開始想法子去結(jié)合一個(gè)新的條件去封裝一個(gè)新的組件。 由于用戶更加熱衷于帶

    2024年02月12日
    瀏覽(20)
  • Bootstrap select2之下拉框可自定義輸入和選擇

    Bootstrap select2之下拉框可自定義輸入和選擇

    1. 引入css文件 2. 引入js文件 3. select標(biāo)簽引入class 我是在項(xiàng)目搜索框部分要加一個(gè)下拉框,本來甚至不需要上面那么多引入,都可以有一個(gè)下拉框,但是要求點(diǎn)擊可以出現(xiàn)輸入框自定義輸入來篩選,然后想到了這個(gè)。但是想要利用表單來實(shí)現(xiàn),因?yàn)椴皇且环N表單,所以樣式混亂

    2024年02月05日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包