Vue 使用 Mint UI 实现左滑删除效果(CellSwipe)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/latency_cheng/article/details/79579052
Mint UI 是饿了么开源的,基于 Vue.js 的移动端组件库。
关于Mint UI,有文档不够准确详尽,组件略显粗糙,功能不够完善等问题;也有高度组件化,体积小等优点。

安装Mint UI:
# Vue 1.x
npm install mint-ui@1 -S
# Vue 2.0
npm install mint-ui -S

引入组件:
// 引入全部组件
import Mint from 'mint-ui';
import 'mint-ui/lib/style.css'
Vue.use(Mint);
// 按需引入部分组件
import { CellSwipe } from 'mint-ui';
Vue.component(CellSwipe.name, CellSwipe);

文档中摘录API,Slot如下:


代码示例:
<ul class="list">
    <li class="item" v-for="section in sectionList">
        <mt-cell-swipe
            :right="[
                {
                    content: '删除',
                    style: { background: '#ff7900', color: '#fff'},
                    handler: () => deleteSection(section.PartId)
                }
            ]">
            <p class="section">{{section.PartName}}</p>
            <p class="teacher">{{section.TeacherName}}</p>
        </mt-cell-swipe>
    </li>
</ul>
:right 可以定义不止一个按钮,也可以自行修改CellSwipe的默认样式
效果展示:


猜你喜欢

转载自blog.csdn.net/latency_cheng/article/details/79579052