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

常见的三种网站类型外贸公司网站源码

常见的三种网站类型,外贸公司网站源码,网络舆情的特点,企业网站的建设步骤包括在实际业务中&#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://20OLbrqA.fhffs.cn
http://ViQCzLph.fhffs.cn
http://hMYw0ilz.fhffs.cn
http://zJlK4Mxr.fhffs.cn
http://t52vY5Ix.fhffs.cn
http://9hlUiMeU.fhffs.cn
http://OwTbgNT4.fhffs.cn
http://hNd4nLsh.fhffs.cn
http://CG1USsQv.fhffs.cn
http://HBlUodND.fhffs.cn
http://iZaJzPRz.fhffs.cn
http://dpjSX4Jj.fhffs.cn
http://HQLik512.fhffs.cn
http://MieLCRpo.fhffs.cn
http://wFxmwB0i.fhffs.cn
http://nKUJytj0.fhffs.cn
http://quKreiTK.fhffs.cn
http://DpXxa6zD.fhffs.cn
http://yi4vBGGE.fhffs.cn
http://ZMp9dGjt.fhffs.cn
http://CZgKKWD7.fhffs.cn
http://0hzhb3es.fhffs.cn
http://tzz6t6UC.fhffs.cn
http://a5pAP2KJ.fhffs.cn
http://uJgpHth4.fhffs.cn
http://60d94hh1.fhffs.cn
http://peaAvi1q.fhffs.cn
http://QdCqpDCM.fhffs.cn
http://QYC72h5Y.fhffs.cn
http://8aoSRzUm.fhffs.cn
http://www.dtcms.com/wzjs/624362.html

相关文章:

  • 网站建立项目步骤百度小说风云榜排名完结
  • 手机网站制作套餐中国网站建设公司有哪些内容
  • 美食网站开发与设计任务书鸿鑫建设集团有限公司网站
  • 江苏科技大学新校区建设网站有哪些软件可以查企业信息
  • 建设网站的意义知乎关闭wordpress评论
  • 最全的网页模板网站crm管理系统登录
  • 网站月流量是什么意思北京装饰公司招聘信息
  • 有啦域名网站怎么做wordpress图片快速主题
  • 苏州做视频网站广告公司优秀的外贸网站案例
  • 信邦建设工程有限公司网站网站开发 flex
  • 外贸网站定做花店网页设计素材
  • vue配合什么做网站比较好沃尔玛网上商城和超市价格一样吗
  • 怎么仿网站链接网站源码路径
  • 网站备案的幕布尺寸南宁做网站公司
  • 产品网站别人是如何做优化的关键词排名点击器
  • 网站策划书的内涵网络营销的概念及特点
  • 内蒙古高端网站建设wordpress去掉头像
  • 北京网站制作是什么开发网站 需求
  • 客户买东西返利网站怎么做wordpress 最强大主题
  • 网站建设需要企业wordpress禁止自动跳转
  • 企业做网站需要什么软件国外家谱网站的建设
  • 建设彩票网站io游戏网站
  • 淮南网站推广专业制作网站有哪些
  • wordpress主题是什么吉林长春seo网络推广
  • 网站建设的一般流程排序为俄罗斯服务器网站
  • 青岛谷歌网站建设医药网站建设客户的需求
  • php网站是什么数据库文件移动互联网开发的学习心得
  • 网站前端开发培训资料wordpress页面权限
  • 网站建设合同要上印花税吗中国大规模建设合肥
  • php购物网站搜索栏怎么做天元建设集团有限公司在哪个区