vue2-trigger-method
v1.0.1
Published
```sh npm install --save vue2-trigger-method ```
Downloads
2
Readme
Installation
npm install --save vue2-trigger-method
yarn add vue2-trigger-method
Usage
Global registration
import TriggerMethod from "vue2-trigger-method";
Vue.use(TriggerMethod);
Local registration
import TriggerMethod from "vue2-trigger-method";
export default {
components: {
TriggerMethod,
},
};
Usage
<div id="app">
<div v-if="show">this will be shown after 2000 ms</div>
<trigger-method @trigger="triggered"></trigger-method>
<trigger-method @trigger="triggeredAfter(1000)" :delay="1000"></trigger-method>
<trigger-method @trigger="show = true" :delay="2000"></trigger-method>
</div>
const vue = new Vue(
el:"#app",
data(){
return {
show:false
}
},
methods:{
triggered() {
console.log("triggered");
},
triggeredAfter(ms) {
console.log(`called after ${ms}ms.`);
}
}
);
On Component
<template>
<trigger-method @trigger="triggered"></trigger-method>
<trigger-method @trigger="triggeredAfter(1000)" :delay="1000"></trigger-method>
</template>
<script>
import { Component, Vue } from "vue-property-decorator";
@Component({})
export default class DemoClass extends Vue {
triggered() {
console.log("triggered");
}
triggeredAfter(ms) {
console.log(`called after ${ms}ms.`);
}
}
</script>