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

做奢侈品的网站正规电商培训班

做奢侈品的网站,正规电商培训班,wordpress 数据表设计,手机网站 后台由于es6支持哈希&#xff0c;所以数据量只要不太大&#xff0c;就不需要对el-cascader进行点击后在调接口出现下一级&#xff0c;很简单的就是直接获取所有数据。 <template><div><el-cascader :modelValue"modelValue" :props"innerProps"…

 由于es6支持哈希,所以数据量只要不太大,就不需要对el-cascader进行点击后在调接口出现下一级,很简单的就是直接获取所有数据。

<template><div><el-cascader :modelValue="modelValue" :props="innerProps" :options="options" @change="handleChange" filterable:show-all-levels="showAllLevels" :disabled="disabled" :placeholder="placeholder" :clearable="clearable"style="width:100%" @blur="onBlur" @focus="onFocus" @close="handleClose" @visible-change="onVisibleChange" /><!-- --- {{ modelValue }} --></div>
</template><script lang="ts" setup>
import { ref, reactive, toRaw, onMounted, watch, onBeforeUnmount } from 'vue'
import type { CascaderProps } from 'element-plus'
import * as api from "./api.js";const props = defineProps({modelValue: {type: Array,default: []},// 是否支持清空选项clearable: {type: Boolean,default: true,},// 是否多选// multiple: {//     type: Boolean,//     default: false,// },// 指定某省,传入该自治区的areacodedesignation: {type: String,default: '',},// 仅显示最后一级showAllLevels: {type: Boolean,default: true,},// 是否禁用disabled: {type: Boolean,default: false,},// 输入框占位文本placeholder: {type: String,default: '',},// 是否选择任意一级选项,还是最后叶子结点checkStrictly: {type: Boolean,default: true,},// 次级菜单的展开方式,click和hoverexpandTrigger: {type: String,default: 'click',},// 多选个数限制selectNummultipleSelectNum: {type: Number,default: 1,},// 省市县乡镇,显示层级,默认为2,到区县。0为省,1为市,2为区县,3为乡镇level: {type: Number,default: 2,},
})let options: any = ref([])  //树
const watchArr = ref([])onMounted(() => {// 获取全量数据getAllData()
})//重新定义一个值来接受prop
const isMultiple = ref(false)//因为prop中的值非动态响应,所以需要通过watch监听,immediate 初始化时接收父组件中的传值
watch(() => props.multipleSelectNum, () => {// isMultiple.value = props.multipleSelectNum;if(props.multipleSelectNum > 1) {isMultiple.value = true}console.log(isMultiple.value,props.multipleSelectNum,'---props.multipleSelectNum;');}, {immediate: true
})onBeforeUnmount(() => {})const emit = defineEmits(['update:modelValue', 'change'])
const handleChange = (e: any, e2: any) => {watchArr.value = eemit('change', e)emit('update:modelValue', e)
}async function getAllData() {let res = await api.SearchAdministrativeDivisions({queryArea: props.designation,level: props.level})options.value = res.data
}function onFocus(e: any) { }
async function onBeforeFilter(e: any) {let res = await api.SearchAdministrativeDivisions({queryArea: e})const fn = (arr: any[]) => {arr.forEach((item, index) => {if (item.children && item.children.length) {item.children = fn(item.children)} else {if (item.children) delete item.children}})return arr}// console.log(options, '---options');options.value = fn(res.data)
}
// const isMultiple = ref(false)
const innerProps: CascaderProps = {checkStrictly: props.checkStrictly,// lazy: true,value: 'areaCode',label: 'name',multiple: isMultiple.value, //modifyexpandTrigger: props.expandTrigger,
}
const handleClose = () => { }
const onBlur = () => {// console.log('---onBlur');
}
const onVisibleChange = (e: any) => {// if (props.modelValue.length < props.multipleSelectNum && props.multiple == true) {if (props.modelValue.length < props.multipleSelectNum && isMultiple.value == true) { //modifyfunction onRabbit(list: any) {list.forEach((el: any) => {if (el.children && el.children.length > 0) {el.children = onRabbit(el.children);}el.disabled = false;el.isFlag = false});return list;}const newList = onRabbit(options.value);options.value = newList;}
}
// 监听
watch(() => watchArr.value,(newVal, oldVal) => {// if (props.multiple == true) {if (isMultiple.value == true) {   //modify// console.log(oldVal,`watch监听变化前的数`)// console.log(newVal, `watch监听变化后的数据`)if (newVal.length >= props.multipleSelectNum) {function onRabbit(list: any) {list.forEach((el: any) => {if (el.children && el.children.length > 0) {el.children = onRabbit(el.children);}newVal.forEach((v: any) => {if (v[v.length - 1] != el.areaCode) {if (el.isFlag) {} else {el.disabled = trueel.isFlag = true}} else {el.disabled = falseel.isFlag = true}})});return list;}const newList = onRabbit(options.value);options.value = newList;} else {function onRabbit(list: any) {list.forEach((el: any) => {if (el.children && el.children.length > 0) {el.children = onRabbit(el.children);}el.disabled = false;el.isFlag = false});return list;}const newList = onRabbit(options.value);options.value = newList;}}},{immediate: true, // 立即执行deep: true // 深度监听}
)
</script><style></style>

http://www.bjxfkj.com.cn/article/104865.html

相关文章:

  • 怎么做百度网站会显示图片在旁边百度升级最新版本下载安装
  • 站群建站系统公众号推广方法
  • php网站开发答辩问的问题网站优化排名优化
  • 优化神马排名软件东莞优化seo
  • 江苏城市建设档案馆网站百度收录快的发帖平台
  • 柳州企业网站开发平台各网站收录
  • 建设网站的定位关键词挖掘工具免费
  • 冀州网站制作seo整站怎么优化
  • 网站如何换服务器山东seo百度推广
  • 做网站没灵感宁波seo推广服务电话
  • 网站自己做流量优化疫情防控措施
  • 网站建设中...b站暴躁姐
  • 深圳的企业排名网站优化公司哪家效果好
  • 怎样做才能发布你的网站网络销售平台排名前十
  • 工商管理网站百度网站搜索排名
  • 九寨沟网站建设规划书网络推广包括哪些
  • 重庆南坪网站建设公司北京网站优化排名
  • 沧州市网站建设价格西安计算机培训机构哪个最好
  • wordpress读不出媒体库seo技术培训泰州
  • 金融公司网站规划方案seo策略是什么意思
  • 外贸手机网站模板怎么建立网站卖东西
  • 如何注册公司网站域名谷歌play
  • joomla 1.5 网站建设基础教程电商网站项目
  • 上海高级网站建设免费seo公司
  • 济南建站公司模板网络优化软件
  • 设计师网站1688域名停靠网页推广大全2023
  • 莱州网站建设效果sem工资
  • win10使用dw做网站百度明星人气榜排名
  • 秒速网站建设乔拓云智能建站官网
  • 漳州微网站建设公司打开百度网址