Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
vue-mb-touch
Advanced tools
Readme
vue-mb-touch 是一个vue的移动端的事件项目,内置了点击(tap)事件,长按(press)事件
demo 后面会抽空写出来
npm install vue-mb-touch
<template>
<div v-touch.press.tap @tap="tap" @press="press">
</div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import vueMobileTouch from "vue-mb-touch";
Vue.use(vueMobileTouch);
@Component
export default class Home extends Vue {
public tap() {
/** tap */
}
public press(e: Event) {
/** press */
}
public data() {
return {
};
}
}
</script>
开启代理模式
<template>
<ul v-touch.proxy @tap="tap($event)" >
<li data-proxy data-index="1"></li>
<li data-proxy data-index="2"></li>
<li data-proxy data-index="3"></li>
</ul>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import vueMobileTouch from "vue-mb-touch";
Vue.use(vueMobileTouch);
@Component
export default class Home extends Vue {
public tap(e: event) {
const currentTarget = e.currentTarget as HTMLElement;
console.log(currentTarget.tagName.toLowerCase()); // li
console.log(JSON.stringify(currentTarget.dataset)); // {proxy: "", index: "1"}
}
public data() {
return {
};
}
}
</script>
在引入 vue-mb-touch 时,可以传入一个全局配置对象。该对象目前支持 maxDistance 与 pressTime, maxDistance 用于手指在屏幕上移动多长距离内可触发事件默认10,pressTime 用于手机按住屏幕多长时间触发长按事件,默认650。具体操作如下:
import Vue from 'vue';
import vueMobileTouch from "vue-mb-touch";
Vue.use(vueMobileTouch, {maxDistance: 10,pressTime: 650});
参数名 | 描述 |
---|---|
tap | 是否开启tap事件,默认不开启,但是在tap和press都不开启时,则自动开启 |
press | 是否开启press事件,默认不开启 |
stop | 是否阻止事件冒泡,默认不阻止 |
prevent | 是否阻止游览器默认行为,默认不阻止 |
passive | 是否为passive监听器,如果有该参数,则阻止游览器默认行为无效 |
capture | 是否为捕获监听器,默认不是 |
proxy | 是否开启事件代理模式,默认不开启, 开启后台 在需要触发事件的目标元素上添加 data-proxy 即可 |
如果是在vue封装的组件上使用 v-touch 指令, 在监听事件时,需要加上 native 参数
FAQs
vue-mb-touch是一个vue的移动端的事件项目,内置了点击(tap)事件,长按(press)事件
The npm package vue-mb-touch receives a total of 3 weekly downloads. As such, vue-mb-touch popularity was classified as not popular.
We found that vue-mb-touch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.