vue-multi-ref

a vue v2 directive to bind the same ref for more than one element
1,517 12
Install
npm install vue-multi-ref
Latest Version:2.0.1
Older releases:2
License:MIT
Last Updated:Jan 3, 2023
Links: GitHub  ·  npm
Maintainer: ctf0

Vue Multi Ref
npm npm

This is a directive to help use same ref on more than one element.

Big thanx to @Herteby & @LinusBorg. :fire::metal::clap:

original post.

Installation

npm install vue-multi-ref --save

Usage

  • register the directive

    import Vue from 'vue'
    import 'vue-multi-ref'
    
    new Vue({ el: '#app' })
    

    or using Vue as global variable

    window.Vue = require('vue')
    require('vue-multi-ref')
    
    new Vue({ el: '#app' })
    
  • now add v-multi-ref:refName to any number of elements that you want to have the same ref, ex.

    • refName could be
      • camelCase = refName
      • kebab-case = ref-name
      • snake-case = ref_name
    <div v-multi-ref:my-ref>a</div>
    <li v-multi-ref:my-ref>b</li>
    <a v-multi-ref:my-ref>c</a>
    
  • result

    // console.log(this.$refs['my-ref'])
    
    > my-ref: (3) [div, li, a]
    

Related Packages

vue3-highlight-text

a vue3 directive of highlight text

84,789
vue-proportion-directive

vue 固定元素比例指令

6,003 10
ardirectives

Ardirectives

811
vue-on-click-outside

vue mixin/directive that does something when you click outside a container

169,297 31
vue-bind-once

A tiny, SSR-safe directive for binding random data to an element.

152,016 169

Version History

Version Released Vue License
2.0.1 MIT
2.0.0 MIT
1.0.2 MIT
1.0.1 ^2.0.0 MIT
1.0.0 MIT