Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize the function of dragging elements by using Native js in vue2.0

Shulou Source: shulou.com Published: 2022-05-31 12:07:18 10月03日 Update

This article mainly introduces "vue2.0 uses native js to achieve drag and drop element function". In daily operation, I believe many people have doubts about how vue2.0 uses native js to achieve drag element function. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the question of "vue2.0 uses native js to achieve drag element function". Next, please follow the editor to study!

Examples are as follows:

. select-item {background-color: # 5bc0de; display: inline-block; text-align: center; border-radius: 3px; margin-right: 10px; cursor:pointer; padding: 6px 20px; color: # fff;} .cursored {cursor: default;}. Project-content,.people-content {margin: 30px 50px;}. People-content {margin-top: 30px;}. Drag-div {border: 1px solid # 5bc0de; padding:10px; margin-bottom: 10px; width: 800px; cursor:pointer } .select-project-item {display: inline-block; text-align: center; border-radius: 3px.drag-people-label {margin-bottom:0; padding-right:10px;} [v-cloak] {display:none;} {{pjdt.name}} {{ppdt.name}}: var dom Var ss = new Vue ({'el':'#dragCon', data: {projectdatas: [{id:1, name:' grape'}, {id:2, name:' mango'}, {id:3, name:' papaya'}, {id:4, name:' durian'}] Peopledata: [{id:1, name:' Xiaoying'}, {id:2, name:'hover'}, {id:3, name:' empty nest youth 3'}, {id:3, name:' lost'}]} Mounted:function () {this.$nextTick (function () {})}, watch: {projectdatas: {handler:function (val,oldval) {}, deep:true}, peopledata: {handler:function (val,oldval) {}, deep:true}} Methods: {drag:function (event) {dom = event.currentTarget}, drop:function (event) {event.preventDefault () Event.target.appendChild (dom);}, allowDrop:function (event) {event.preventDefault ();}})

Achieve results:

At this point, the study on "how vue2.0 uses native js to drag and drop elements" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Elements functions learning more help practical next effects articles methods papaya durian theory knowledge examples empty nests articles websites mangoes grapes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Docker Shulou Tech Info macOS Apple