vue-selector

0.0.1 • Public • Published

Vue selector

A component selector for Vue

Travis npm

How to use

Vue selector is a plugin of Vue, just install it by Vue.use

Vue.use(VueSelector)

Assert you have a component tree like this:

Root
 └ ComA
    ├ ComB
    ├ ComC
    │  └ ComD
    └ ComB

You can query components just like using css selector and querySelectorAll method:

root.$querySelectorAll('ComA ComB')
// get [ComB, ComB]
 
root.$querySelectorAll('ComA > ComC')
// get [] because ComA have no child ComC
 
root.$querySelectorAll('ComC + ComB')
// get [ComB(after ComC)]
 
root.$querySelectorAll('ComA, ComD')
// get [ComA, ComD]

$querySelectorAll method will search components base on the component call it, that is ComB.$querySelectorAll('ComD') will get nothing because there is no ComD belongs to ComB.

Note that component is selected according to it's name, which was given in component option.

Readme

Keywords

none

Package Sidebar

Install

npm i vue-selector

Weekly Downloads

44

Version

0.0.1

License

MIT

Last publish

Collaborators

  • cool_zjy