- Notifications
You must be signed in to change notification settings - Fork5
simple vue plugin to implement underscore
License
NotificationsYou must be signed in to change notification settings
HKskn/vue-underscore
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
You know Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects.I arranged it as a vue plugin to use on your projects.
- Vue.js
2.x
# npm$ npm install vue-underscore
After using the plugin on main.js. You can call it simply with 'this.$_.findwhere' (each, map, reduce, filter...)
main.js
importVuefrom'vue';importunderscorefrom'vue-underscore';importAppfrom'./App';Vue.use(underscore);newVue({ ...App}).$mount('#app');
If you wouldn't like to access from vue prototype, you can add underscore on the component source code directly via below.
import{_}from'vue-underscore';lettestArr=[{id:1},{id:2}];letfoundInfo=_.findWhere(testArr,{id:1});
<script>exportdefault{methods:{test(){lettestArr=[{id:1},{id:2}];letfoundInfo=this.$_.findWhere(testArr,{id:1});}}}</script>