Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report