vue ios 滑动卡顿_Vue.js的iOS样式滑动操作

本文介绍了Vue.js中实现iOS风格滑动操作的组件`vue-swipe-actions`,包括安装、道具配置和基本用法,同时讨论了在iOS设备上可能出现的滑动卡顿问题。
摘要由CSDN通过智能技术生成

vue ios 滑动卡顿

滑动提示动作 (vue-swipe-actions)

iOS style swipe actions for Vue.js.

Vue.js的iOS样式滑动操作。

安装 (Installation)

npm install vue-swipe-actions
import { SwipeList, SwipeOut } from 'vue-swipe-actions';

export default {
  components: {
    SwipeOut,
    SwipeList
  }
};
道具 (Props)
PropData TypeRequiredDescription
itemsArraytrueYour array with data
transition-keyStringYour key for :key when list is v-for-ed, default (id)
transitionStringStringYour transition-group string name, default (swipe-list-item)
Struts 数据类型 需要 描述
items 数组 真正 您的数据数组
transition-key 列表为v-for-ed时,:key的密钥,默认(id)
transitionString 您的过渡组字符串名称,默认(swipe-list-item)
基本用法 (Basic Usage)
<swipe-list class="card" :items="mockSwipeList" transition-key="id" @swipeout:contentclick="contentClick" @swipeout:click="itemClick" @swipeout:doubleclick="itemDblClick">
  <template slot-scope="{ item, index, revealLeft, revealRight, close }">
    <!-- item is the corresponding object from the array -->
    <!-- index is clearly the index -->
    <!-- revealLeft is method which toggles the left side -->
    <!-- revealRight is method which toggles the right side -->
    <!-- close is method which closes an opened side -->
    <div class="card-content">
      <!-- style content how ever you like -->
      <h2>{{ item.title }}</h2>
      <p>{{ item.description }}</p>
      <span>{{ index }}</span>
    </div>
  </template>
  <template slot="left" slot-scope="{ item }">
    <!-- left swipe side template and slot-scope="{ item }" is the item clearly -->
    <!-- remove <template slot="left" slot-scope="{ item }"> if you dont wanna have left swipe side  -->
    <div class="swipeout-action action-panel-left">
      <div>
        <!-- place icon here or what ever you want -->
        <i class="fa fa-cloud"></i>
      </div>
      <div>
        <!-- place icon here or what ever you want -->
        <i class="fa fa-file"></i>
      </div>
    </div>
  </template>
  <template slot="right" slot-scope="{ item }">
    <!-- right swipe side template and slot-scope="{ item }" is the item clearly -->
    <!-- remove <template slot="right" slot-scope="{ item }"> if you dont wanna have right swipe side  -->
    <div class="swipeout-action action-panel-right">
      <div>
        <!-- place icon here or what ever you want -->
        <i class="fa fa-heart"></i>
      </div>
    </div>
  </template>
  <div slot="empty">
    <!-- change mockSwipeList to an empty array to see this slot in action  -->
    list is empty ( filtered or just empty )
  </div>
</swipe-list>
components: {
  SwipeOut,
  SwipeList,
},
data() {
  return {
    mockSwipeList: [
      {
        id: 0,
        key1: 'key1',
        key2: 'key2',
        key3: 'key3',
        key4: 'key4',
      },
      {
        id: 1,
        key1: 'key1',
        key2: 'key2',
        key3: 'key3',
        key4: 'key4',
      },
      {
        id: 2,
        key1: 'key1',
        key2: 'key2',
        key3: 'key3',
        key4: 'key4',
      },
    ],
  };
},
methods: {
  contentClick(e) {
    console.log(e, 'content click');
  },
  itemClick(e) {
    console.log(e, 'item click');
  },
  itemDblClick(e) {
    console.log(e, 'item double click');
  },
  fbClick(e) {
    console.log(e, 'First Button Click');
  },
  sbClick(e) {
    console.log(e, 'Second Button Click');
  },
},
SCSS样式要求 (SCSS style requires)

npm install sass-loader node-sass --save-dev

npm install sass-loader node-sass --save-dev

<style lang="scss">
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");

.swipeout-list {
	display: flex;
	flex-direction: column;
}
.swipeout-action {
  display: flex;
  > div {
    display: flex;
    align-items: center;
    padding: 0 3rem;
    cursor: pointer;
  }
  &.action-panel-right {
    > div {
      background-color: dodgerblue;
      color: white;
      &:hover {
        background-color: darken(dodgerblue, 5%);
      }
    }
  }
  &.action-panel-left {
    > div:nth-of-type(even) {
      background-color: darkorchid;
      color: white;
      &:hover {
        background-color: darken(darkorchid, 5%);
      }
    }
    > div:nth-of-type(odd) {
      background-color: dodgerblue;
      color: white;
      &:hover {
        background-color: darken(dodgerblue, 5%);
      }
    }
  }
}
.swipeout-list-item {
	flex: 1;
	border-bottom: 1px solid lightgray;
	&:last-of-type {
		border-bottom: none;
	}
}
.card {
  width: 100%;
	background-color: white;
	border-radius: 3px;
	box-shadow: none;
	border: 1px solid lightgray;
}
.card-content {
  padding: 1rem;
}
</style>

翻译自: https://vuejsexamples.com/ios-style-swipe-actions-for-vue-js/

vue ios 滑动卡顿

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值