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

用ps做网站方法个人网站开发网

用ps做网站方法,个人网站开发网,wordpress acf图片插件,wordpress get_currentuserinfo前端时间有个需求,需要对33(不一定,也可能多行)的卡片布局,进行拖拽,拖拽过程中自动排序,以下代码是基于vue2,可直接运行,报错可评论滴我 部分代码优化来自于GPT4o和Clau…

前端时间有个需求,需要对3×3(不一定,也可能多行)的卡片布局,进行拖拽,拖拽过程中自动排序,以下代码是基于vue2,可直接运行,报错可评论滴我

部分代码优化来自于GPT4o和Claude:官方直连GPT/Claude

在这里插入图片描述

代码如下:

<template><div style="width: 600px; height: 2000px;margin-top:20px"><hr /><br /><button @click="addItem">添加元素</button><div class="container" style="width: 100%; margin-top: 10px; height: 100%"><grid-layout:layout="layout":col-num="colNum":row-height="30":vertical-compact="false":use-css-transforms="true"@layout-updated="layoutUpdatedEvent" ><grid-itemv-for="item in layout":key="item.i":x="item.x":y="item.y":w="item.w":h="item.h":i="item.i"><span class="text">{{ item.scene }}</span></grid-item></grid-layout></div></div>
</template><script>
import { GridLayout, GridItem } from "vue-grid-layout";
export default {components: {GridLayout,GridItem,},data() {return {layout: [{ x: 0, y: 0, w: 1, h: 2, i: "0", scene: "场景1"},{ x: 1, y: 0, w: 1, h: 2, i: "1", scene: "场景2"},{ x: 2, y: 0, w: 1, h: 2, i: "2", scene: "场景3"},{ x: 0, y: 2, w: 1, h: 2, i: "3", scene: "场景4"},{ x: 1, y: 2, w: 1, h: 2, i: "4", scene: "场景5"},{ x: 2, y: 2, w: 1, h: 2, i: "5", scene: "场景6"},// { x: 2, y: 1, w: 1, h: 2, i: "6", scene: "场景7"},// { x: 3, y: 1, w: 1, h: 2, i: "7", scene: "场景8"},// { x: 0, y: 2, w: 1, h: 2, i: "8", scene: "场景9"}],draggable: true,resizable: false,responsive: true,colNum: 3,index: 0,initialized:false,isUpdating: false,layoutCopy: []};},mounted() {this.index = this.layout.length;},methods: {layoutUpdatedEvent(newLayout) {if (!this.isUpdating) {this.isUpdating = true;this.rearrangeLayout(newLayout);this.$nextTick(() => {this.isUpdating = false;});}},rearrangeLayout(layout) {// 创建 layout 的深拷贝,防止修改原始数据let newLayout = layout;// 按 y 和 x 排序newLayout.sort((a, b) => a.y - b.y || a.x - b.x);// 重新排列布局for (let i = 0; i < newLayout.length; i++) {newLayout[i].x = (i % 3) * 1;newLayout[i].y = Math.floor(i / 3)*newLayout[i].h;}this.layout= newLayout;},addItem(){// Add a new item. It must have a unique key!this.layout.push({x: (this.layout.length * 1) % (this.colNum || 12),// q:为什么* 2 a:因为每个元素的宽度是2y: this.layout.length + (this.colNum || 12), // puts it at the bottomw: 1,h: 2,i: this.index,scene: `场景${this.layout.length + 1}`});console.log(this.layout,"this.layout");// Increment the counter to ensure key is always unique.this.index++;},removeItem(){const index = this.layout.map(item => item.i).indexOf(val);this.layout.splice(index, 1);},}
};
</script><style>
.container .vue-grid-item.vue-grid-placeholder {background: none;border: #00893d dashed 2px;
}
.vue-grid-layout {background: #eee;
}
.vue-grid-item:not(.vue-grid-placeholder) {background: #00893d;border: 1px solid #00893d;
}
.vue-grid-item .resizing {opacity: 0.9;
}
.vue-grid-item .static {background: #cce;
}
.vue-grid-item .text {font-size: 24px;text-align: center;position: absolute;top: 0;bottom: 0;left: 0;right: 0;margin: auto;height: 100%;width: 100%;color: #FFF;
}
.vue-grid-item .no-drag {height: 100%;width: 100%;
}
.vue-grid-item .minMax {font-size: 12px;
}
.vue-grid-item .add {cursor: pointer;
}
.vue-draggable-handle {position: absolute;width: 20px;height: 20px;top: 0;left: 0;background-position: bottom right;padding: 0 8px 8px 0;background-repeat: no-repeat;background-origin: content-box;box-sizing: border-box;cursor: pointer;
}
.layoutJSON {background: #ddd;border: 1px solid #00893d;margin-top: 10px;padding: 10px;
}
.columns {-moz-columns: 120px;-webkit-columns: 120px;columns: 120px;
}
</style>
http://www.hkea.cn/news/20301/

相关文章:

  • 东莞市阳光网青岛seo服务
  • 网站弹窗在中间位置企业培训师
  • 整站下载器 安卓版域名解析查询站长工具
  • 跨境自建站模板seo推广是做什么
  • 网站建设与网页设计报告网络营销师报名入口
  • 生成前端页面的网站东莞网络营销全网推广
  • 网站及单位网站建设情况免费男女打扑克的软件
  • 公司有网站有什么好处网上开店如何推广自己的网店
  • 海口网站建设策划关键词排名优化工具有用吗
  • 请问哪里可以做网站汕头seo
  • 访问国外网站速度慢苏州关键词seo排名
  • 做网站备案照片的要求谷歌seo教程
  • wordpress站点全屏新站如何让百度快速收录
  • wordpress 会议 主题推广排名seo
  • 源码开发网站建设sem与seo的区别
  • 如何查网站的空间防恶意点击软件
  • 单位网站建设收费标准互联网推广引流
  • 网站有中文源码加英文怎么做关键词歌词完整版
  • 建设网站企业银行做网站的平台
  • 如何进行网站建设分析网站推广app软件
  • 做ppt的软件模板下载网站网站服务公司
  • 网站icp备案认证怎么做谷歌网页版入口在线
  • 高安网站建设艺考培训
  • 主流的网站开发技术百度推广后台管理
  • 传奇网站模板免费下载优化网络搜索引擎
  • 提升学历报考什么专业比较好seosem顾问
  • 做违法网站犯法吗推广费用一般多少钱
  • 网站版权该怎么做呢五种常用的网站推广方法
  • 周宁县建设局网站关键词挖掘站网
  • 做第三方团购的平台网站全网线报 实时更新