当前位置: 首页 > news >正文

网站建设天津长沙推广引流

网站建设天津,长沙推广引流,福田官方网站,阳江公司做网站基于Element UI的el-select组件进行封装的。该组件实现了一个下拉选择框&#xff0c;具有许多可配置的属性和事件 创建组件index.vue (src/common-ui/select/index.vue) <template><el-selectref"select"v-model"hValue":allow-create"allo…

基于Element UI的el-select组件进行封装的。该组件实现了一个下拉选择框,具有许多可配置的属性和事件

创建组件index.vue (src/common-ui/select/index.vue)
<template><el-selectref="select"v-model="hValue":allow-create="allowCreate":autocomplete="autocomplete":automatic-dropdown="automaticDropdown":clearable="clearable":collapse-tags="collapseTags":default-first-option="defaultFirstOption":disabled="disabled":filter-method="filterMethod":filterable="filterable":loading="loading":loading-text="loadingText":multiple="multiple":multiple-limit="multipleLimit":name="name":no-match-text="noMatchText":no-data-text="noDataText":placeholder="placeholder":popper-class="popperClass":popper-append-to-body="popperAppendToBody":remote="remote":remote-method="remoteMethod":reserve-keyword="reserveKeyword":size="size":key="poperKeyValue":value-key="valueKey"@blur="handleBlur"@change="handleChange"@clear="handleClear"@focus="handleFocus"@remove-tag="handleRemoveTag"@visible-change="handleVisibleChange"><slot name="prefix" slot="prefix"></slot><slot name="option-content"><template v-for="(item, index) in dataSource"><el-option-groupv-if="item[hProps.options] &&item[hProps.options].length > 0 &&!selectSpecial":key="index":label="item[hProps.label]":disabled="item[hProps.disabled]"><el-optionv-for="(option, subIndex) in item[hProps.options]":key="subIndex":label="option[hProps.label]":value="option[hProps.value]":disabled="option[hProps.disabled]"></el-option></el-option-group><el-optionv-else-if="!item[hProps.options] && !selectSpecial":key="index + 'si'":label="item[hProps.label]":value="item[hProps.value]":disabled="item[hProps.disabled]"></el-option><el-optionv-else-if="!item[hProps.options] && selectSpecial":key="index + 'sp'":label="`${item[hProps.label]}(${item[selectSpecial]})`":value="item[hProps.value]":disabled="item[hProps.disabled]"></el-option></template></slot></el-select>
</template><script>
export default {name: 'HSelect',props: {allowCreate: {type: Boolean,default: false},selectSpecial: {type: String,default: ''},autocomplete: String,automaticDropdown: {type: Boolean,default: false},clearable: {type: Boolean,default: true},collapseTags: {type: Boolean,default: false},dataSource: Array,defaultFirstOption: {type: Boolean,default: false},disabled: {type: Boolean,default: false},filterMethod: Function,filterable: {type: Boolean,default: true},loading: {type: Boolean,default: false},loadingText: String,multiple: {type: Boolean,default: false},multipleLimit: Number,name: String,noMatchText: String,noDataText: String,placeholder: String,popperClass: {type: String,default: 'select-default'},popperAppendToBody: {type: Boolean,default: true},remote: {type: Boolean,default: false},remoteMethod: Function,reserveKeyword: {type: Boolean,default: false},size: {type: String,validator (value) {return ['medium', 'small', 'mini'].indexOf(value) !== -1}},value: {type: [String, Number, Array, Boolean],required: true},valueKey: String,props: {type: Object,default () {return {}}},keyValue: {type: String,default: 'select-single'},align:{type: String,default: 'center'}},data () {return {poperKeyValue: ''}},computed: {hValue: {get () {let value = nullif (this.multiple) {value = []if (this.value instanceof Array) {this.value.forEach(key => {if (this.checkValueExisting(key)) {value.push(key)}})}} else {value = ''if (this.checkValueExisting(this.value)) {value = this.value}}return value},set (value) {this.$emit('input', value)}},hProps () {return {label: 'name',value: 'id',disabled: 'disabled',options: 'options',...this.props}}},watch: {keyValue (val) {this.poperKeyValue = val}},methods: {checkValueExisting (value) {if (this.allowCreate) {return value} else {if (this.dataSource instanceof Array) {let index = this.dataSource.findIndex(item => item[this.hProps.value] === value,this)return index > -1}return false}},handleBlur (event) {this.$emit('blur', event)},handleChange (value) {this.$emit('change', value)},handleClear () {this.$emit('clear')},handleFocus (event) {this.$emit('focus', event)},handleRemoveTag (tag) {this.$emit('remove-tag', tag)},handleVisibleChange (visible) {this.$emit('visible-change', visible)},focus () {this.$refs.select.focus()},blur () {this.$refs.select.blur()}}
}
</script><style lang="scss" scoped></style>
页面引入
  • 在需要使用HSelect组件的地方,通过import语句引入HSelect组件注册并使用
<template><div><h-select :data-source="dataSource" v-model="selectedValue"></h-select></div>
</template>
<script >import HSelect from '@/common-ui/select/index'export default {components: {HSelect},data() {return {dataSource:[],selectedValue: ''}}// ...}
</script>

确保你已经安装了Vue.js和Element UI,并在项目中引入它们。

http://www.shuangfujiaoyu.com/news/54967.html

相关文章:

  • 网页设计作品代码在哪里找海外广告优化师
  • 做搬家网站推广在那好网络推广应该怎么做啊
  • 快速做网站服务好漯河seo公司
  • 如何将下载好的网站模板用到织梦程序上邢台网站公司
  • 商城网站策划宁波seo网络推广报价
  • 太原专业做网站电商产品推广方案
  • 个人网站的建设与管理seo模拟点击软件源码
  • dw做的网站设计360优化大师官方免费下载
  • 珠海网站建设网络公司怎么样市场营销案例分析及解答
  • 安丘做网站的公司品牌营销推广要怎么做
  • 网站建设没有预付款友链互换平台推荐
  • 淘宝网做宝贝详情用哪个网站百度免费收录提交入口
  • 网站界面设计案例分析淘宝店铺推广
  • 网站滑动效果怎么做的深圳网络营销怎么推广
  • 论坛怎么做网站链接品牌网络营销策划书
  • 四川省住房建设厅网站进不去人工智能培训课程
  • wordpress开启子站seo属于什么
  • 做网站的哪家好大搜推广
  • python做视频点播网站百度网站首页入口
  • 给个网站免费的打开免费百度啊
  • 做网站还是租用服务器企业培训心得体会
  • 做微商哪个网站比较好新闻播报最新
  • 电子商务网站建设 试卷重庆seo公司
  • 试用体验网站新闻头条最新消息国家大事
  • 阿里云个人备案可以做企业网站吗软文写作300字
  • 网页制作个人介绍模板西安网站seo推广
  • 企业名录怎么导出苏州seo关键词优化报价
  • 网站建站常见问题百度站长工具是什么意思
  • 政府网站集约化建设告知书今日时事新闻
  • 云建网站网址seo优化技术培训