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

网站建设的安全应该注意什么苏州三大建筑设计院

网站建设的安全应该注意什么,苏州三大建筑设计院,网站开发建设计入什么科目,网页的设计与应用的论文在实际业务中&#xff0c;我们经常遇到「标签排序」或「菜单调整」的场景。微信小程序原生的 movable-view 为我们提供了一个简单、高效的拖拽能力&#xff0c;结合 Vue3 uni-app 的组合&#xff0c;我们可以实现一个体验良好的标签管理界面。 核心组件&#xff1a;<movab…

在实际业务中,我们经常遇到「标签排序」或「菜单调整」的场景。微信小程序原生的 movable-view 为我们提供了一个简单、高效的拖拽能力,结合 Vue3 + uni-app 的组合,我们可以实现一个体验良好的标签管理界面

核心组件<movable-view><movable-area>

1.每项数据结构加入 y 坐标

const itemHeight = uni.upx2px(110); // 每项高度,决定拖动步长function initDragg(list) {return list.map((item, index) => ({...item,y: index * itemHeight, // 初始位置}));
}

2. 拖动状态管理变量

const canDrag = ref(false);          // 当前是否允许拖动(长按才激活)
const draggingIndex = ref(-1);       // 当前拖动的 item 的 index

3.用户手指按下某项

<image@touchstart="canDrag = true":src="getSpecImgUrl('sort_set')"
/>

4.进入拖动状态

function onTouchStart(index) {if (!canDrag.value) return;draggingIndex.value = index;
}

5.拖动过程中(自动触发)

function onChange(e, index) {const dy = e.detail.y;const targetIndex = Math.round(dy / itemHeight);if (targetIndex !== index && targetIndex >= 0 && targetIndex < groupList.value.length) {// 拖动项移到新位置const moved = groupList.value.splice(index, 1)[0];groupList.value.splice(targetIndex, 0, moved);draggingIndex.value = targetIndex;} else {// 仅移动视觉,不换位置groupList.value[index].y = dy;}
}

6.拖动结束

function onTouchEnd() {if (!canDrag.value) return;draggingIndex.value = -1;// 所有项重置为标准位置groupList.value.forEach((item, i) => {item.y = i * itemHeight;});// 同步顺序到后端sortLabelList(groupList.value);canDrag.value = false;
}

完整代码测试代码

<template><scroll-view scroll-y style="height: 100vh"><movable-area style="height: 1000rpx; width: 100vw; position: relative"><block v-for="(item, index) in list" :key="item.id"><movable-viewdirection="vertical"damping="50"inertia:y="item.y":style="getStyle(index)"@touchstart="onTouchStart(index)"@touchend="onTouchEnd"@change="onChange($event, index)"><view class="item">{{ item.name }}</view></movable-view></block></movable-area></scroll-view>
</template><script setup>import { ref, reactive, onMounted } from 'vue';import { debounce } from '@/utils/util';const itemHeight = 100; // 每项高度,单位 rpx(需配合实际样式调整)const list = reactive([{ id: 1, name: '任务一', y: 0 },{ id: 2, name: '任务二', y: 100 },{ id: 3, name: '任务三', y: 200 },{ id: 4, name: '任务四', y: 300 },]);let draggingIndex = ref(-1);function onTouchStart(index) {draggingIndex.value = index;}function onTouchEnd(e, index) {console.log(444);draggingIndex.value = -1;// 重置 Y 防止漂移list.forEach((item, i) => {item.y = i * itemHeight;});}// 拖拽过程中计算是否需要交换function onChange(e, index) {// const bounce = debounce(foo,500);// bounce()const dy = e.detail.y;const targetIndex = Math.round(dy / itemHeight);console.log(2222,e,index,targetIndex);if (targetIndex !== index &&targetIndex >= 0 &&targetIndex < list.length) {console.log(3333);// 交换数据const moved = list.splice(index, 1)[0];list.splice(targetIndex, 0, moved);// 重新设置 y 值// list.forEach((item, i) => {//   item.y = i * itemHeight;// });draggingIndex.value = targetIndex;} else {list[index].y = dy;}}function getStyle(index) {return `position: absolute; left: 0; width: 100%; height: ${itemHeight}rpx; z-index: ${draggingIndex.value === index ? 10 : 1};`;}
</script><style scoped>.item {background-color: #f1f1f1;margin: 10rpx;border-radius: 10rpx;text-align: center;line-height: 100rpx;box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);}
</style>

http://www.dtcms.com/a/493942.html

相关文章:

  • 做男装比较好的网站有哪些网站素材站
  • 2017年网站建设视频教程网页设计尺寸1920
  • 网站插件模块原理wordpress使用redis
  • 做同性恋网站犯法吗石家庄抖音代运营公司
  • 邢台做网站优化邯郸市市长
  • 萤火虫网站建设优化建设物流网站
  • 建设网站公司怎么分工如何建网站赚钱
  • 建设网站的工作总结建筑工程培训课程
  • 长沙做网站公司有哪些wordpress适合做官网
  • 学校网站建设汇报ppt海南建设监理协会网站
  • 网站前台可以打开建设网站模板免费
  • 关于网站制作的论文哪家建站好
  • 集团网站改版方案做网页的软件h
  • 免费公司网站怎么做网站布局图片
  • 做网站还要做点手机吗正中路桥建设发展有限公司网站
  • 全网站开发是什么营销网站有哪些
  • 上海专业网站建设多少钱wordpress密码进入网站
  • 古田住房与建设局网站广昌网站建设
  • 什么网站值得做推广公司的网站可以采取哪些方式
  • 濮阳网站建设推广2w网站2w网站建设建设
  • 网站建设方案书备案注册域名哪个网站好
  • 做营销型网站公司深圳网站营销公司简介
  • 如何做影视剧网站下列哪个不是网络营销成熟阶段出现的网络营销方式
  • 泰州网站制作平台潮州专业网站建设制作
  • 永嘉县住房和城乡建设局网站网页代码编辑器
  • .net招聘网站怎么做网站收录了没有排名
  • 广东网站建设方便企业网站推广建议
  • 化妆网站建设的目的大流量网站建设
  • iis 多网站信誉楼线上商城小程序
  • 一个网站需要多少钱深圳哪里做网站好