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

Mint UI 是饿了么开源的,基于 Vue.js 的移动端组件库。
关于Mint UI,有文档不够准确详尽,组件略显粗糙,功能不够完善等问题;也有高度组件化,体积小等优点。

安装Mint UI:
[python] view plain copy
  1. # Vue 1.x  
  2. npm install [email protected]1 -S  
  3. # Vue 2.0  
  4. npm install mint-ui -S  

引入组件:
[javascript] view plain copy
  1. // 引入全部组件  
  2. import Mint from 'mint-ui';  
  3. import 'mint-ui/lib/style.css'  
  4. Vue.use(Mint);  
  5. // 按需引入部分组件  
  6. import { CellSwipe } from 'mint-ui';  
  7. Vue.component(CellSwipe.name, CellSwipe);  

文档中摘录API,Slot如下:

Vue 使用 Mint UI 实现左滑删除效果(CellSwipe
代码示例:
[html] view plain copy
  1. <ul class="list">  
  2.     <li class="item" v-for="section in sectionList">  
  3.         <mt-cell-swipe  
  4.             :right="[  
  5.                 {  
  6.                     content: '删除',  
  7.                     style: { background: '#ff7900', color: '#fff'},  
  8.                     handler: () => deleteSection(section.PartId)  
  9.                 }  
  10.             ]">  
  11.             <p class="section">{{section.PartName}}</p>  
  12.             <p class="teacher">{{section.TeacherName}}</p>  
  13.         </mt-cell-swipe>  
  14.     </li>  
  15. </ul>  
:right可以定义不止一个按钮,也可以自行修改CellSwipe的默认样式
效果展示:
Vue 使用 Mint UI 实现左滑删除效果(CellSwipe