H5有基于拖拽的事件机制,如果你还不熟悉,请看我之前的文章【拖拽上传】中有介绍。
原生拖拽API实现
由于比较简单直接上代码了:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>拖拽排序</title>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.min.js"></script>
<style>
ul {
clear: both;
list-style: none;
overflow: hidden;
}
li {
cursor: pointer;
float: left;
height: 32px;
line-height: 30px;
padding: 0 10px;