mint-ui 左滑删除 + 传参
可以在leftButtonHandler加弹出层效果并且传参:
XML/HTML Code复制内容到剪贴板
- <mt-cell-swipe class="user-publish-item" v-for="(item, index) in publishList" :key="item.publishId" :right="[{content: delTemplate,handler: () => deletePublish(item.publishId)}]" >
左侧出现的模板:
JavaScript Code复制内容到剪贴板
- data: function() {
- delTemplate:'<div class="delBtn"><i class="fa fa-trash-o" aria-hidden="true"></i></div>', //左侧删除的模板
JS:
JavaScript Code复制内容到剪贴板
- methods: {
- deletePublish(val){
- //删除发布
- this.$messagebox.confirm('', {
- message: '是否确定删除?',
- confirmButtonText: '确定',
- cancelButtonText: '取消'
- }).then(action => {
- console.log(val);
- }).catch(err => {
- //this.$toast('您已取消删除');
- })
- },
DEMO1:
XML/HTML Code复制内容到剪贴板
- <template>
- <mt-cell-swipe class="user-publish-item" v-for="(item, index) in publishList" v-show="!item.show" :key="item.publishId" :value="item.publishId" :right="[{content: delTemplate,handler: () => deletePublish(index,item.publishId)}]">
- {{item.title}}
- </mt-cell-swipe>
- </template>
- <script>
- methods: {
- deletePublish(index, id) {
- //删除
- this.$messagebox.confirm('', {
- message: '是否确定删除?',
- confirmButtonText: '确定',
- cancelButtonText: '取消'
- }).then(action => {
- this.$indicator.open();
- /* 第一种 */
- this.publishList.splice(index, 1); //删除数组中一组
- /* 第二种 */
- this.$set(this.publishList[index], 'show', true);
- }).catch(err => {
- this.$indicator.close(); //关闭loading
- this.$toast("网络连接失败");
- })
- },
- }
- </script>
文档上的demo:
XML/HTML Code复制内容到剪贴板
- <template>
- <div class="page-cell">
- <div class="page-title">Cell Swipe</div>
- <mt-cell-swipe
- v-for="n in 15"
- :right="rightButtons"
- title="swipe me">
- </mt-cell-swipe>
- </div>
- </template>
- <script>
- export default {
- created() {
- this.rightButtons = [
- {
- content: 'Mark as Unread',
- style: { background: 'lightgray', color: '#fff' }
- },
- {
- content: 'Delete',
- style: { background: 'red', color: '#fff' },
- handler: () => this.leftButtonHandler
- }
- ];
- },
- methods: {
- leftButtonHandler(evt) {
- console.log(123);
- }
- }
- };
- </script>
API
option | description | type | acceptable values | default |
---|---|---|---|---|
icon | cell icon | String | back, more | |
title | title of the cell | String | ||
to | link | String | ||
value | content of the cell | * | ||
label | a description shown underneath the title | String | ||
is-link | if the cell is a link, works with the to attribute |
Boolean | ||
left | button group, { content, style, handler } |
Object[] | ||
right | button group, { content, style, handler } |
Object[] |
Slot
name | description |
---|---|
- | custom content |
title | custom title |
icon | custom icon |
上一篇 vue calender日历插件
下一篇 mint-ui Radio