当前位置:网站首页>ionic4 ion-reorder-group组件拖拽改变item顺序
ionic4 ion-reorder-group组件拖拽改变item顺序
2022-06-30 09:50:00 【全栈程序员站长】
2018在ionic项目中用到的组件有很多,这篇文章讲一讲ion-reorder-group这个组件的使用。刚开始我都不知道ionic4中已经封装了拖拽排序的组件,也是主管告诉我的。使用了这个组件的经历告诉我:仔细读官方文档,是没错的! HTML中使用组件,代码如下
<!--一个排序组合一个ion-reorder-group-->
<ion-reorder-group [disabled]="false" (ionItemReorder)="reorder($event)">
<ion-item color="tertiary" *ngFor="let field of fieldList,let i=index">
<ion-label>{
{ field.name}}</ion-label>
<!--拖拽按钮-->
<ion-reorder slot="end"></ion-reorder>
</ion-item>
</ion-reorder-group>ionItemReorder绑定reorder事件,是item被拖拽时会被触发的事件,这个事件是ionic绑定在IonReorderGroup组件上的。记得一定要设置disabled属性,不然不会有拖拽按钮出现。
reorder(ev) {
try {
if (ev.detail.to === this.fieldList.length) {
ev.detail.to -= 1;
}
if (ev.detail.from < ev.detail.to) {
this.fieldList.splice(ev.detail.to + 1, 0, this.fieldList[ev.detail.from]);
this.fieldList.splice(ev.detail.from, 1);
}
if (ev.detail.from > ev.detail.to) {
this.fieldList.splice(ev.detail.to, 0, this.fieldList[ev.detail.from]);
this.fieldList.splice(ev.detail.from + 1, 1);
}
ev.detail.complete();
} catch (e) {
return;
}
}customEvent继承自Event,添加了detail属性,包含from,to,complete,分别记录拖拽条目的前后index,complete方法需在拖拽结束后调用,否则会卡住。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/101149.html原文链接:https://javaforall.cn
边栏推荐
- CSDN博客运营团队2022年H1总结
- Auto Seg-Loss: 自动损失函数设计
- CVPR 2022 | Tsinghua & bytek & JD put forward BRT: Bridging Transformer for vision and point cloud 3D target detection
- 乡村振兴公益基金启动暨古茶树非遗保护公益行发布
- MIT-6874-Deep Learning in the Life Sciences Week5
- Compétences Comb 27 @ Body sense Manipulator
- 《锦绣中华》中老年公益文旅游-走进佛山敬老院
- Es common curl finishing
- Use keil5 software to simulate and debug gd32f305 from 0
- Deploy lvs-dr cluster
猜你喜欢

The programmer was beaten.

How to seize the opportunity of NFT's "chaos"?

CSDN博客运营团队2022年H1总结

MySQL index, transaction and storage engine of database (2)

How to deploy deflationary combustion destruction contract code in BSC chain_ Deploy dividend and marketing wallet contract code

Jump table introduction

移植完整版RT-Thread到GD32F4XX(详细)

Oracle creates a stored procedure successfully, but the compilation fails

Basic MySQL operation commands of database

Get through the supply chain Shenzhen gift show helps cross-border e-commerce find ways to break the situation
随机推荐
Deployment of efficient and versatile clusters lvs+kept highly available clusters
Action bright: take good care of children's eyes together -- a summary of the field investigation on the implementation of action bright in Guangxi
Deploy lvs-dr cluster
技能梳理[email protected]+adxl345+电机震动+串口输出
Who should the newly admitted miners bow to in front of the chip machine and the graphics card machine
Koreano essential creates a professional style
Robotframework learning notes: environment installation and robotframework browser plug-in installation
光明行动:共同呵护好孩子的眼睛——广西实施光明行动实地考察调研综述
Splendid China: public welfare tourism for the middle-aged and the elderly - entering Foshan nursing home
I found a wave of "alchemy artifact" in the goose factory. The developer should pack it quickly
Koreano essential creates a professional style
Jinbei LT6 is powerful in the year of the tiger, making waves
Memorize the text and remember the words. Read the text and remember the words. Read the article and remember the words; 40 articles with 3500 words; 71 articles broke through the words in the middle
A brief introduction to database mysql
Dyson design award, changing the world with sustainable design
Use keil5 software to simulate and debug gd32f305 from 0
Leetcode question brushing (IV) -- greedy thought (go Implementation)
技能梳理[email protected]在oled上控制一条狗的奔跑
《锦绣中华》中老年公益文旅游-走进佛山敬老院
Open source! Wenxin large model Ernie tiny lightweight technology, accurate and fast, full effect