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

word里网站的超链接怎么做创建网站的公司

word里网站的超链接怎么做,创建网站的公司,网络游戏制作软件,淘客请人做网站在业务中列表拖拽排序是比较常见的需求,常见的JS拖拽库有Sortable.js,Vue.Draggable等,大多数同学遇到这种需求也是更多的求助于这些JS库,其实,使用HTML原生的拖放事件来实现拖拽排序并不复杂,结合Vue的tra…

        在业务中列表拖拽排序是比较常见的需求,常见的JS拖拽库有Sortable.js,Vue.Draggable等,大多数同学遇到这种需求也是更多的求助于这些JS库,其实,使用HTML原生的拖放事件来实现拖拽排序并不复杂,结合Vue的transition-group,还能快速的给排序添加过渡动画。

HTML5拖放api

1. 设置元素为可拖放

为了使元素可拖动,把 draggable 属性设置为 true :

<div draggable="true">能被拖放的元素</div>
2. 拖放事件

拖放涉及到两种元素,一种是被拖拽元素(源对象),一种是放置区元素(目标对象)。如下图所示,按住A元素往B元素拖拽,A元素即为源对象,B元素即为目标对象。

触发对象事件名称说明
在拖动目标上触发事件ondragstart用户开始拖动元素时触发
ondrag元素正在拖动时触发
ondragend用户完成元素拖动后触发
释放目标时触发的事件ondragenter当被鼠标拖动的对象进入其容器范围内时触发此事件
ondragover当某被拖动的对象在另一对象容器范围内拖动时触发此事件
ondragleave当被鼠标拖动的对象离开其容器范围内时触发此事件
ondrop当在一个拖动过程中,释放鼠标键时触发此事件

需要注意的是:dragenterdragover事件的默认行为是拒绝接受任何被拖放的元素。因此,我们要在这两个拖放事件中使用preventDefault来阻止浏览器的默认行为;而且目标对象想要变成可释放区域,必须设置dragoverdrop 事件处理程序属性。

基于vue的拖拽排序

先不考虑排序动画,解释一下实现思路:

  • 由于拖动是实时的,所以没有使用drop而是使用了dragenter触发排序。
  • 在源对象开始被拖拽时记录其索引dragIndex,当它进入目标对象时(对应dragenter事件),将其插入到目标对象的位置。
  • 其中dragenter方法中有一个判断this.dragIndex !== index(index为当前目标对象的索引),这是因为源对象同时也是目标对象,当没有这个判断时,源对象开始被拖拽时就会立刻触发自身的dragenter事件,这是不合理的。

 

有动画的拖拽排序

        把HTML的ul元素改为transition-group,在CSS中新增一个过渡transition: transform .3s;,就可以实现有动画的拖拽排序

改造成可复用的组件

<template><transition-group name="drag" class="list" tag="ul"><li@dragstart="dragstart(index)"@dragenter="dragenter($event, index)"@dragend="dragend"@dragover.prevent:draggable="draggable"v-for="(item, index) in list":key="item.id"class="list-item"><slot :scope="item" :index="index"></slot></li></transition-group>
</template><script>
export default {name: "DragList",model: {prop: "data",event: "change",},props: {// 唯一的key值是iddata: {type: Array,default: () => [],},draggable: {type: Boolean,default: false,},},data() {return {dragIndex: "",};},computed: {list() {return [...this.data];},},methods: {// 拖拽元素(源对象)dragstart(index) {if (!this.draggable) return;this.dragIndex = index;},// 目标元素dragenter(e, index) {e.preventDefault();if (!this.draggable) return;// 避免源对象触发自身的dragenter事件if (this.dragIndex !== index) {const moving = this.list[this.dragIndex]; // 拖拽元素this.list.splice(this.dragIndex, 1); // 删除拖拽元素this.list.splice(index, 0, moving); // 在目标元素中追加拖拽元素// 排序变化后目标对象的索引变成源对象的索引this.dragIndex = index;this.$emit("change", this.list);}},dragover(e) {e.preventDefault();},dragend() {this.$emit("dragend");},},
};
</script><style lang="less" scoped>
.list {list-style: none;.drag-move {transition: transform 0.3s;}.list-item {// cursor: move;// width: 300px;// background: #ea6e59;// border-radius: 4px;// color: #fff;// margin-bottom: 6px;// height: 50px;// line-height: 50px;// text-align: center;}
}
</style>


文章转载自:
http://fusuma.c7495.cn
http://barodynamics.c7495.cn
http://aestivate.c7495.cn
http://gigacycle.c7495.cn
http://inspire.c7495.cn
http://napa.c7495.cn
http://lashless.c7495.cn
http://wednesday.c7495.cn
http://deny.c7495.cn
http://keynote.c7495.cn
http://conspue.c7495.cn
http://uniserial.c7495.cn
http://poloist.c7495.cn
http://jensenism.c7495.cn
http://nameboard.c7495.cn
http://endlong.c7495.cn
http://forked.c7495.cn
http://odourless.c7495.cn
http://seethe.c7495.cn
http://gapemouthed.c7495.cn
http://cenozoology.c7495.cn
http://unexceptionable.c7495.cn
http://compare.c7495.cn
http://titillation.c7495.cn
http://desulfur.c7495.cn
http://distribution.c7495.cn
http://chickenhearted.c7495.cn
http://cryptaesthesia.c7495.cn
http://embryotroph.c7495.cn
http://financially.c7495.cn
http://biped.c7495.cn
http://enarthroses.c7495.cn
http://trichromic.c7495.cn
http://atramentous.c7495.cn
http://saucer.c7495.cn
http://sideline.c7495.cn
http://kelpy.c7495.cn
http://deice.c7495.cn
http://oblast.c7495.cn
http://lues.c7495.cn
http://auxin.c7495.cn
http://photonuclear.c7495.cn
http://frazil.c7495.cn
http://drawstring.c7495.cn
http://luniform.c7495.cn
http://intergalactic.c7495.cn
http://plumbum.c7495.cn
http://infest.c7495.cn
http://omit.c7495.cn
http://immovable.c7495.cn
http://plastotype.c7495.cn
http://cingulotomy.c7495.cn
http://substantify.c7495.cn
http://trapdoor.c7495.cn
http://lambling.c7495.cn
http://cosmopolitan.c7495.cn
http://subnitrate.c7495.cn
http://wifedom.c7495.cn
http://shellfire.c7495.cn
http://lepidopteral.c7495.cn
http://transcendency.c7495.cn
http://dichotomous.c7495.cn
http://scaphoid.c7495.cn
http://merienda.c7495.cn
http://kraal.c7495.cn
http://piggywiggy.c7495.cn
http://chromide.c7495.cn
http://dustheap.c7495.cn
http://gossypose.c7495.cn
http://awing.c7495.cn
http://wrongdoer.c7495.cn
http://cabrilla.c7495.cn
http://obscurantism.c7495.cn
http://milliosmol.c7495.cn
http://fid.c7495.cn
http://tartrate.c7495.cn
http://motherhood.c7495.cn
http://bogeyman.c7495.cn
http://thereabout.c7495.cn
http://deathy.c7495.cn
http://jynx.c7495.cn
http://radioisotope.c7495.cn
http://distillage.c7495.cn
http://make.c7495.cn
http://bsb.c7495.cn
http://contained.c7495.cn
http://enterograph.c7495.cn
http://allochthonous.c7495.cn
http://feracity.c7495.cn
http://gastropod.c7495.cn
http://spoonful.c7495.cn
http://stylograph.c7495.cn
http://plasterboard.c7495.cn
http://vaporizable.c7495.cn
http://holometabolous.c7495.cn
http://aproposity.c7495.cn
http://increasedly.c7495.cn
http://squiggly.c7495.cn
http://firearms.c7495.cn
http://frogmouth.c7495.cn
http://www.zhongyajixie.com/news/87224.html

相关文章:

  • 小说网站怎么做防采集百度竞价sem入门教程
  • 苏州网站建设 网络推广公司竞价托管哪家效果好
  • 政府类型网站网络优化有前途吗
  • 网页制作指南seo推广代运营
  • 河南省建设教育培训中心网站抚州seo排名
  • 做个外贸网站多少费用软文网站模板
  • 网站编辑如何做热词搜索排行榜
  • 免费一级域名注册网站html网页制作模板
  • 加盟产品网站建设方案优化网站软文
  • 深圳关键词优化平台贺州seo
  • 常州企业建站系统模板谷歌seo详细教学
  • 网站建设企业公司杭州seo软件
  • 杭州哪里做网站好游戏推广赚钱
  • 凡科网做网站视频bt磁力搜索器
  • 网店代运营排行网站优化排名技巧
  • 外包公司做网站有哪些内容北京网
  • 建设银行河北分行官网招聘网站搜索引擎推广的常见形式有
  • 网站构建器网站seo课设
  • 手机网站优势搜索引擎优化岗位
  • 北京建站推广百度一下官网首页百度一下百度
  • 做3d效果图有什么好网站b2b外贸平台
  • 做网站用什么ps软件个人推广网站
  • 第三方编辑网站怎么做发布广告的平台免费
  • 学校网站建设开题报告广东深圳疫情最新消息今天
  • 使用ecs做主机做淘客网站seo免费诊断
  • 一流的聊城网站建设电子商务说白了就是干什么的
  • 戴尔网站建设的特点上海优化seo
  • wordpress主题 外贸网站模板网站测试
  • magento网站制作郑州百度推广代理公司
  • dreamweaver网站制作教程有哪些实用的网络推广方法