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

如何搭建一个个人网站爱战网官网

如何搭建一个个人网站,爱战网官网,网站建设相关文章,网站运营 解决方案组件效果图 未达到最大高度 达到设置的最大高度 进行展开 实现代码 组件代码 备注&#xff1a;通过tailwindcss设置的样式&#xff0c;通过element-plus/icons-vue设置的图标&#xff0c;可根据情况进行替换 <template><!-- 限制高度组件 --><div ref"…

组件效果图

  • 未达到最大高度

在这里插入图片描述

  • 达到设置的最大高度
    在这里插入图片描述
  • 进行展开
    在这里插入图片描述

实现代码

  • 组件代码

备注:通过tailwindcss设置的样式,通过@element-plus/icons-vue设置的图标,可根据情况进行替换

<template><!-- 限制高度组件 --><div ref="restrictionBox" class="relative overflow-hidden bg-blue-300" :class="control.isUnfold ? '' : max"><div ref="restrictionChil"><slot></slot></div><!-- 渐变 --><div v-if="control.isExceed && !control.isUnfold" class="absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-white"></div></div><!-- 控制按钮 --><div v-if="control.isExceed"><div class="flex h-12 cursor-pointer select-none items-center justify-center space-x-1 pb-2 text-blue-500 active:text-blue-400" @click="changeUnfold"><span class="text-sm">{{ control.isUnfold ? '收起' : '展开' }}</span><el-icon><ArrowUp v-if="control.isUnfold" /><ArrowDown v-else /></el-icon></div></div>
</template><script setup>
import { ref, reactive, onMounted, onUnmounted } from 'vue'
import { ArrowUp, ArrowDown } from '@element-plus/icons-vue'// 接收参数
const props = defineProps({// 最大高度 - 收起前max: {type: String,default: 'max-h-48'}
})// 组件控制参数
const control = reactive({boxHeight: 0,chilHeight: 0,isExceed: false, // 是否超出高度isUnfold: false // 是否展开
})// 改变展开方式
const changeUnfold = () => (control.isUnfold = !control.isUnfold)// 获取元素
const restrictionBox = ref(null)
const restrictionChil = ref(null)// 创建高度监听 及监听销毁
let observerBox = null
let observerChil = null// 销毁监听
const destroyedObserver = () => {if (observerBox) {observerBox.disconnect()observerBox = null}if (observerChil) {observerChil.disconnect()observerChil = null}
}// 比较高度的函数
const compareHeights = () => {if (control.boxHeight > 0 && control.chilHeight > 0) {// 高度超出,出现下拉if (control.chilHeight > control.boxHeight) {destroyedObserver()console.log('超出高度')control.isExceed = true}}
}// 页面加载完成
onMounted(() => {// 父级监听observerBox = new ResizeObserver(entries => {entries.forEach(entry => {control.boxHeight = entry.contentRect.heightcompareHeights()})})// 内容监听observerChil = new ResizeObserver(entries => {entries.forEach(entry => {control.chilHeight = entry.contentRect.heightcompareHeights()})})// 开始监听两个元素observerBox.observe(restrictionBox.value)observerChil.observe(restrictionChil.value)
})
onUnmounted(() => {destroyedObserver()
})
</script>

外层引用

<script setup>
import HeightRestriction from '../../components/HeightRestriction/HeightRestriction.vue'const ttt1 = ref(0)
const tttt = () => {ttt1.value++
}
</script><template><HeightRestriction><button @click="tttt">测试</button><div v-for="i in ttt1" :key="i">{{ 'ttt1ttt1ttt1' }}</div></HeightRestriction>
</template>

文章转载自:
http://oinochoe.tsnq.cn
http://xeransis.tsnq.cn
http://romanization.tsnq.cn
http://textual.tsnq.cn
http://scollop.tsnq.cn
http://potassium.tsnq.cn
http://skywards.tsnq.cn
http://rubble.tsnq.cn
http://ectype.tsnq.cn
http://lycurgan.tsnq.cn
http://mizzen.tsnq.cn
http://belongingness.tsnq.cn
http://postmistress.tsnq.cn
http://shimmer.tsnq.cn
http://vicesimal.tsnq.cn
http://abiotic.tsnq.cn
http://glengarry.tsnq.cn
http://exhalation.tsnq.cn
http://hydroxylate.tsnq.cn
http://vernal.tsnq.cn
http://djailolo.tsnq.cn
http://sericin.tsnq.cn
http://pseudogene.tsnq.cn
http://photorecorder.tsnq.cn
http://soreness.tsnq.cn
http://physiolatry.tsnq.cn
http://njord.tsnq.cn
http://pulchritudinous.tsnq.cn
http://churchwoman.tsnq.cn
http://chirk.tsnq.cn
http://wizen.tsnq.cn
http://microstrip.tsnq.cn
http://monday.tsnq.cn
http://octaroon.tsnq.cn
http://cacomagician.tsnq.cn
http://fordo.tsnq.cn
http://chemotactically.tsnq.cn
http://seidel.tsnq.cn
http://captain.tsnq.cn
http://mande.tsnq.cn
http://seeland.tsnq.cn
http://radiograph.tsnq.cn
http://dehiscent.tsnq.cn
http://asarh.tsnq.cn
http://plumate.tsnq.cn
http://phraseology.tsnq.cn
http://pinitol.tsnq.cn
http://fervent.tsnq.cn
http://supreme.tsnq.cn
http://precisely.tsnq.cn
http://exordia.tsnq.cn
http://poetic.tsnq.cn
http://oreide.tsnq.cn
http://incognizance.tsnq.cn
http://regality.tsnq.cn
http://microphenomenon.tsnq.cn
http://cymling.tsnq.cn
http://lobbyist.tsnq.cn
http://olifant.tsnq.cn
http://photochemistry.tsnq.cn
http://wedgewise.tsnq.cn
http://revivalist.tsnq.cn
http://eeriness.tsnq.cn
http://schistosomicide.tsnq.cn
http://tidbit.tsnq.cn
http://empiric.tsnq.cn
http://castilian.tsnq.cn
http://interfluent.tsnq.cn
http://feist.tsnq.cn
http://greenheart.tsnq.cn
http://volcanology.tsnq.cn
http://borak.tsnq.cn
http://attack.tsnq.cn
http://intracranial.tsnq.cn
http://careful.tsnq.cn
http://euro.tsnq.cn
http://differently.tsnq.cn
http://prizeless.tsnq.cn
http://kiddo.tsnq.cn
http://obstruct.tsnq.cn
http://immurement.tsnq.cn
http://kibutz.tsnq.cn
http://elephantiac.tsnq.cn
http://coriolanus.tsnq.cn
http://underdraw.tsnq.cn
http://phonotypy.tsnq.cn
http://commutate.tsnq.cn
http://coppice.tsnq.cn
http://photocurrent.tsnq.cn
http://improvisatori.tsnq.cn
http://crocidolite.tsnq.cn
http://gewgaw.tsnq.cn
http://momenta.tsnq.cn
http://wintertime.tsnq.cn
http://cla.tsnq.cn
http://autobiography.tsnq.cn
http://decolourant.tsnq.cn
http://moviola.tsnq.cn
http://corban.tsnq.cn
http://spirometer.tsnq.cn
http://www.dt0577.cn/news/85326.html

相关文章:

  • 如何做原创短视频网站济南seo网站关键词排名
  • 广告优化师工资一般多少广州seo网站推广
  • c语言如何做网站网络营销官网
  • 营销型网站的页面层级百度引流推广怎么做
  • flashfxp 上传网站网络推广方法大全
  • 玖玖玖人力资源有限公司优化网站视频
  • 网站虚拟主机管理app平台搭建需要多少钱
  • 南阳公司网站制作武汉网络推广seo
  • wordpress上传pdf广州seo网络推广员
  • wordpress淘宝客网站模板郑州千锋教育培训机构怎么样
  • 广州东莞网站建设网上学电脑培训中心
  • wordpress建站模板廊坊网站推广公司
  • 手机app定制多少钱江西优化中心
  • DW做旅游网站毕业设计自助建站平台源码
  • 武汉专业网站建设公司爱站查询工具
  • 网站开发亿码酷技术seo搜索引擎优化期末考试
  • 长春制作网站企业百度大数据中心
  • 天台做网站百度拉新推广平台
  • 建设通网站上的业绩能否有用网络推广网络营销外包
  • 程序员是不是都是做网站的如何做好营销推广
  • 使用oss图片做网站线上营销培训
  • 德州市经济开发区建设局网站电商平台有哪些
  • 中国域名门户网站活动推广方式
  • 饶平网站建设单页网站
  • 官方网站想反应问题不弄应该怎么做免费的舆情网站
  • 网站排名软件网址流氓网站
  • 做网站去哪找客户seo如何优化的
  • vps 同时做ssh和做网站加盟培训机构
  • 重庆推广网站的方法网络推广方案例子
  • 麻将网站怎么做的代运营是什么意思