Vueo
🍟 Easy to get value from vue instance via object paths.
Installation
npm i vueo -S
Import
import Vue from 'vue'
import Vueo from 'vueo'
Vue.use(Vueo)
Or import via script tag
<script src="path/to/vue/dist/vue.js"></script>
<script src="path/to/vueo/dist/vueo.js"></script>
Usage
new Vue({
data () {
return {
a: [ { key: 'value' } ],
b: { c: 1 }
}
},
created() {
this.$at('a.0.key') // 'value'
this.$at('a.1.key') // undefined
this.$at(this.a, '0.key') // 'value'
this.$has('b') // true
this.$has('a.1') // false
}
})
API
- vm#$at(path)
- vm#$at(obj, path)
- vm#$has(path)
- vm#$has(obj, path)
Read more
- https://github.com/jonschlinkert/get-value
- https://github.com/jonschlinkert/has-value
License
MIT