vue-lazy-ref
0.1.4 • Public • Published vue-lazy-ref

Easy to get ref even if the element present in async!
This is for vue 2.x
Installing
Using npm:
npm install --save vue-lazy-ref
Using yarn:
Usage
vue-lazy-ref can be used as a vue plugin.
As a vue plugin
var Vue = require('vue');
var vLazyRefPlugin = require('vue-lazy-ref');
Vue.use(vLazyRefPlugin)
Started
Normal case
<template>
<div>
<div ref="test" v-lazy-ref="'test'" />
</div>
</template>
<script>
export default {
...
methods: {
async doAction() {
const el = await this.$getLazyRefs('test');
}
}
</script>
Async case
<template>
<div v-if="show">
<div ref="test" v-lazy-ref="'test'" />
<button @click="show = !show" />
</div>
</template>
<script>
export default {
...
data() {
return {
show: false
};
},
methods: {
async doAction() {
const el = await this.$getLazyRefs('test');
}
}
</script>
<template>
<div v-if="show">
<custom-comp ref="test" v-lazy-ref="'test'" />
<button @click="show = !show" />
</div>
</template>
<script>
export default {
...
data() {
return {
show: false
};
},
methods: {
async doAction() {
const comp = await this.$getLazyRefs('test');
}
}
</script>
License
MIT
Package Sidebar
Install
Weekly Downloads