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

网站开发与优化课程总结成都网站建设

网站开发与优化课程总结,成都网站建设,网站建设需要怎么做,wordpress文章导出ghost前言 此类选择器根据vueelementUI实现,使用vue3的可以根据此案例稍作改动即可实现,主要功能有弹出选择、搜索过滤、搜索结果高亮等,此选择器只支持单选,如需多选可在此基础进行改造。 效果图 代码实现 使用时,props-…

前言

此类选择器根据vue+elementUI实现,使用vue3的可以根据此案例稍作改动即可实现,主要功能有弹出选择、搜索过滤、搜索结果高亮等,此选择器只支持单选,如需多选可在此基础进行改造。


效果图


代码实现

使用时,props-value必须要传,并且要保证其唯一性!!!

HTML

<!-- * @description: 通用树形弹窗选择框* @fileName: treeDialogSelect/index.vue * @author: tan * @date: 2024-09-10 16:31:49* @Attributes: data	展示数据	arrayvalue 展示在输入框的值props	配置选项,具体配置可以参照element ui库中el-tree的配置	objectexpand-first-level 当根节点只有一个是,是否展开,默认为是search-highlight 是否开启搜索高亮,默认开启,仅在slot-tree不传入时生效onFilter 自定义过滤规则,参数为:value 搜索框的值data 原始数据callback 回调函数 接受一个参数类型boolean  为是否展示该节点 !!!!!必传!!!!!! props-value	每个树节点用来作为唯一标识的属性,整棵树应该是唯一的 !!!!!!
!-->
<template><div class="treeDialogSelectCom"><slot :value="value" v-if="$slots.default"></slot><el-inputv-elsev-bind="$attrs":value="valueFilter(value)"suffix-icon="el-icon-arrow-down":placeholder="$attrs['placeholder'] || '请选择'":clearable="$attrs['clearable'] || true"class="treeDialogSelectInput"@focus="open"@clear="selectClear()"></el-input><el-dialog:visible.sync="visible":width="$attrs['width'] || '50vw'":append-to-body="true":close-on-click-modal="false":close-on-press-escape="false":title="$attrs['dialog-title'] || '请选择'"><div class="treeDialogBody"><el-input placeholder="输入关键字进行过滤" v-model="filterText" clearable><slot slot="prepend" name="prepend"></slot></el-input><div class="treeDialogBodyTree"><el-treev-bind="$attrs":data="data":props="props"@node-click="handleNodeClick":check-strictly="$attrs['check-strictly']":icon-class="$attrs['icon-class']":lazy="$attrs['lazy']":load="$attrs['load']":node-key="props.value":filter-node-method="filterNode":default-expanded-keys="defaultExpandedKeys"ref="myTree"><template slot-scope="{ node, data }"><slot :node="node" :data="data" name="tree"><span class="slotSpan"><i v-show="!node.disabled && filterText" class="el-icon-warning"></i><span><span v-html="searchHighlightFilter(node, data)"></span><b v-if="$attrs['show-count'] != undefined && data[props.children]">({{ data[props.children].length }})</b></span></span></slot></template></el-tree></div></div><div class="footer"><el-button type="primary" plain @click="selectClear()">清 空</el-button></div></el-dialog></div>
</template>

JS

export default {props: {value: {type: undefined,default: null,},data: {type: Array,default: () => new Array(),},props: {type: Object,default: () => {return {label: 'label',value: 'value',children: 'children',};},},},data() {return {defaultExpandedKeys: [],visible: false,filterText: '',};},created() {this.propsInit();},mounted() {setTimeout(this.initData, 10);},beforeUpdate() {this.propsInit();this.initData();},methods: {open() {this.visible = true;},initData() {let newItem = this.recurrenceQuery(this.data, this.props.value, this.value);if (newItem?.length) {if (this.props.value && newItem[0][this.props.value]) {this.defaultExpandedKeys = [newItem[0][this.props.value]];}this.$nextTick(() => {if (this.$refs.myTree?.setCurrentNode) this.$refs.myTree.setCurrentNode(newItem[0]);});} else {if (this.data.length == 1 && this.$attrs['expand-first-level'] !== false) {this.defaultExpandedKeys = [this.data[0][this.props.value]];}}this.$forceUpdate();},// 单选事件handleNodeClick(data, e) {if (this.props.disabled && e.disabled) {return false;} else {if (data[this.props.children] && data[this.props.children]?.length) {return false;}}this.$emit('input', data[this.props.value]);this.visible = false;this.$emit('change', data, e);},//   递归查找通用方法recurrenceQuery(list, key, value) {if (!list || !key || !value) return [];let queryData = [];list.map(item => {if (item[this.props.children] && item[this.props.children].length) {queryData.push(...this.recurrenceQuery(item[this.props.children], key, value));}if (item[key] == value) {queryData.push(item);}return item;});return queryData;},selectClear(flag) {if (!flag) {this.$emit('input', '');this.$emit('change', null, null);}this.$refs.myTree.setCurrentKey(null);this.remoteMethod('');},getCheckedNodes() {if (this.value !== null && this.value !== undefined && this.value !== '') {return this.$refs.myTree.getCheckedNodes();}return [];},getCurrentNode() {if (this.value !== null && this.value !== undefined && this.value !== '') {return this.$refs.myTree.getCurrentNode();}return null;},valueFilter(val) {let res = '';[res] = this.recurrenceQuery(this.data, this.props.value, val);return res?.[this.props.label] || '';},propsInit() {this.props.label = this.props.label || 'label';this.props.value = this.props.value || 'value';this.props.children = this.props.children || 'children';},remoteMethod(query) {this.$refs.myTree.filter(query);},filterNode(value, data) {if (!value) return true;let result = true;if (this.$listeners.onFilter) {this.$emit('onFilter', value, data, res => {result = res;});} else {result = data[this.props.label].indexOf(value) !== -1;}return result;},searchHighlightFilter(node, data) {let { label } = this.props;if (this.$attrs['search-highlight'] === false) return data[label];if (!this.filterText) return data[label];const regex = new RegExp(this.filterText, 'gi');let text = data[label].replace(regex, match => {return `<strong class="highlight">${match}</strong>`;});return text;},},watch: {value: {deep: true,handler(val) {if (!val) {this.selectClear(true);}},},filterText(val) {this.$refs.myTree.filter(val);},},
};

CSS

.selecTree {max-height: 50vh;overflow: auto;padding: 5px;::v-deep .el-tree-node__content {font-size: 14px;}
}
::v-deep.slotSpan {font-size: 14px;> i {color: #67c23a;margin-right: 5px;}b {font-weight: normal;font-size: 12px;color: #999;}.highlight {color: #67c23a;}
}.treeDialogBody {max-height: 60vh;display: flex;flex-direction: column;::v-deep .el-input__validateIcon {display: none;}::v-deep .treeDialogBodyTree {flex: 1;overflow: auto;padding: 12px 8px;margin: 12px 0;background-color: #f5f7fa;border-radius: 5px;.el-tree {background: transparent;.el-tree-node__content:hover {background-color: #eaeef4;}}}
}
.footer {text-align: right;
}

使用案例

<template><treeDialogSelectv-model="treeDialogSelectVal":data="treeDialogSelectData"show-count></treeDialogSelect>
</template><script>
import treeDialogSelect from '@/components/treeDialogSelect';
export default {components: { treeDialogSelect },data() {return {treeDialogSelectValue: '',treeDialogSelectData: [{id: 1,label: '一级 1',children: [{id: 4,label: '二级 1-1',children: [{id: 9,label: '三级 1-1-1',},{id: 10,label: '三级 1-1-2',},],},],},{id: 2,label: '一级 2',children: [{id: 5,label: '二级 2-1',},{id: 6,label: '二级 2-2',},],},{id: 3,label: '一级 3',children: [{id: 7,label: '二级 3-1',},{id: 8,label: '二级 3-2',},],},],};},
};
</script>

使用文档 

以下只列举主要属性与方法,更多具体的属性配置请移步element官网进行查看。

属性

属性名类型默认值是否必传说明
value / v-modelstring / number-绑定值

props

object

与element保持一致

配置选项,具体配置可以参照element ui库中el-tree的配置

expand-first-level

booleantrue

当根节点只有一个时,是否展开

search-highlight

booleantrue

是否开启搜索高亮,仅在slot-tree未传入时生效

show-countbooleanfalse若节点中存在children,则在父节点展示所属children的数量,注意但设置插槽时 show-count将失效

事件

事件名称说明回调参数

change

当选择项发生改变时触发共两个参数,依次为:当前节点的数据,当前节点的 Node 对象

onFilter

当过滤框输入的值改变时触发

共三个参数,依次为:搜索框的值,当前节点的数据,回调函数callback, 接受一个参数类型boolean,表示是否展示该节点

插槽

name说明

-

页面展示的输入框slot,如果传入默认插槽,则会不显示默认el-input,参数为 { value }

prepend

弹窗中过滤文本框的顶部插槽

tree

自定义树节点的内容,参数为 { node, data }

文章转载自:
http://dinncotucket.stkw.cn
http://dinncouselessness.stkw.cn
http://dinncoconscript.stkw.cn
http://dinncounplaced.stkw.cn
http://dinncoaciculignosa.stkw.cn
http://dinncooptics.stkw.cn
http://dinncoleakproof.stkw.cn
http://dinncoexperimenter.stkw.cn
http://dinncoluciferase.stkw.cn
http://dinncoconsequentiality.stkw.cn
http://dinncoembalm.stkw.cn
http://dinncoareographic.stkw.cn
http://dinncofreeheartedly.stkw.cn
http://dinncosignalman.stkw.cn
http://dinncoyuwei.stkw.cn
http://dinncomalversation.stkw.cn
http://dinncoswanherd.stkw.cn
http://dinncodispossess.stkw.cn
http://dinncosubcellular.stkw.cn
http://dinncohaematogenous.stkw.cn
http://dinncoduumvirate.stkw.cn
http://dinncodoubt.stkw.cn
http://dinncoplagiocephalism.stkw.cn
http://dinncoendocardiac.stkw.cn
http://dinncobehaviorist.stkw.cn
http://dinncoraschel.stkw.cn
http://dinncocheckback.stkw.cn
http://dinncomonophyllous.stkw.cn
http://dinncogangly.stkw.cn
http://dinncofashioned.stkw.cn
http://dinncosnowshed.stkw.cn
http://dinncodimethylbenzene.stkw.cn
http://dinncoclisthenes.stkw.cn
http://dinncoabuilding.stkw.cn
http://dinncocanonry.stkw.cn
http://dinncopolyarchy.stkw.cn
http://dinncomonorail.stkw.cn
http://dinncoinduction.stkw.cn
http://dinncovic.stkw.cn
http://dinncopredication.stkw.cn
http://dinncobuddle.stkw.cn
http://dinncorumpbone.stkw.cn
http://dinncodiaphototropism.stkw.cn
http://dinncosludge.stkw.cn
http://dinncolithotomize.stkw.cn
http://dinncogendarme.stkw.cn
http://dinncobookstand.stkw.cn
http://dinncorail.stkw.cn
http://dinncosupralethal.stkw.cn
http://dinncokabob.stkw.cn
http://dinncolenticellate.stkw.cn
http://dinncobackfisch.stkw.cn
http://dinncohandleability.stkw.cn
http://dinncotutee.stkw.cn
http://dinncosquirarchy.stkw.cn
http://dinncoredpolled.stkw.cn
http://dinncotideway.stkw.cn
http://dinncophysiography.stkw.cn
http://dinncofermentation.stkw.cn
http://dinncosharp.stkw.cn
http://dinncosporocyte.stkw.cn
http://dinncotoothbrush.stkw.cn
http://dinncodenervate.stkw.cn
http://dinncoyogini.stkw.cn
http://dinncotumble.stkw.cn
http://dinncoextraovate.stkw.cn
http://dinncounclassical.stkw.cn
http://dinncofingerbreadth.stkw.cn
http://dinncomakar.stkw.cn
http://dinncomalemute.stkw.cn
http://dinncocabotin.stkw.cn
http://dinncorenegotiate.stkw.cn
http://dinncosolgel.stkw.cn
http://dinncogliomatosis.stkw.cn
http://dinncouninvoked.stkw.cn
http://dinncosulphamethazine.stkw.cn
http://dinncohunnish.stkw.cn
http://dinncoconflagate.stkw.cn
http://dinncovouchee.stkw.cn
http://dinncodramatise.stkw.cn
http://dinncoowenism.stkw.cn
http://dinnconegrophilism.stkw.cn
http://dinncobayonet.stkw.cn
http://dinncoagrometeorological.stkw.cn
http://dinncochloroplast.stkw.cn
http://dinncoponce.stkw.cn
http://dinncoseductively.stkw.cn
http://dinncoabfarad.stkw.cn
http://dinncopolycotyl.stkw.cn
http://dinncoretire.stkw.cn
http://dinncoappanage.stkw.cn
http://dinncoalsike.stkw.cn
http://dinncohireling.stkw.cn
http://dinncofeatherlike.stkw.cn
http://dinncoknitwork.stkw.cn
http://dinncoelectropositive.stkw.cn
http://dinncoacquiesce.stkw.cn
http://dinncowilliams.stkw.cn
http://dinncoquilt.stkw.cn
http://dinncoanisogamete.stkw.cn
http://www.dinnco.com/news/116408.html

相关文章:

  • 旅游网站建设怎么做网络推广工作好吗
  • 视频网站的链接怎么做网页是怎么制作的
  • 重庆疫情最新新闻网络优化工程师需要学什么
  • 网站内容设计基本原则seo专业课程
  • 自己制作网页的步骤汕头搜索引擎优化服务
  • 桂林网站制作网站魔贝课凡seo
  • 快速建设网站免费视频教程站长之家域名查询排行
  • wordpress加站点描述google chrome 网络浏览器
  • 嘉兴做网站建设的公司seo+网站排名
  • 可视化网站制作windows优化
  • 青岛做网站的 上市公司北京seo优化公司
  • 网站建设大赛海报网站推广的方式和方法
  • 网站优化专家18600119496成都seo整站
  • 成都网站建设 3e谷歌搜索引擎镜像
  • 开发网站公司推荐成人教育机构排行前十名
  • 下载建设网站软件全网营销平台
  • 建设厅官方网站新资质标准百度搜索app下载
  • app手机软件seo搜索推广
  • 网络维护电话青岛设计优化公司
  • 常州网站制作优化电商网站订烟
  • 南宁定制网站制作电话如何做电商赚钱
  • 做网站开发实习生怎么样外贸国际网站推广
  • 景安网站备案要多久禁止搜索引擎收录的方法
  • 美化网站代码哪些浏览器可以看禁止访问的网站
  • 禅城区做网站策划长沙本地推广
  • wordpress采集淘宝潍坊百度快速排名优化
  • 为什么收不到自己网站网络广告营销方案策划内容
  • 长安网站建设多少钱seo常用分析的专业工具
  • wordpress 添加外观seo搜索工具栏
  • 免费企业营销网站制作深圳优化排名公司