https://github.com/HKskn/vue-underscore
simple vue plugin to implement underscore
https://github.com/HKskn/vue-underscore
Last synced: 8 months ago
JSON representation
simple vue plugin to implement underscore
- Host: GitHub
- URL: https://github.com/HKskn/vue-underscore
- Owner: HKskn
- License: mit
- Created: 2017-11-16T23:35:00.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-04-16T12:59:07.000Z (over 5 years ago)
- Last Synced: 2024-10-28T02:59:56.814Z (about 1 year ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 18
- Watchers: 0
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-vue - vue-underscore - simple vue plugin to implement underscore ` 📝 a year ago ` (Utilities [🔝](#readme))
- awesome-vue-zh - Vue下划线 - 用于实现下划线的简单vue插件 (公用事业 / 印花)
- awesome-vue - vue-underscore - simple vue plugin to implement underscore (Components & Libraries / Utilities)
- awesome-vue - vue-underscore ★11 - simple vue plugin to implement underscore (Utilities / Printing)
- awesome-vue - vue-underscore - simple vue plugin to implement underscore (Utilities / Printing)
README
# vue-underscore
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.
[](https://www.npmjs.com/package/vue-underscore)
[](https://www.npmjs.com/package/vue-underscore)
# Table of Contents
* [___Requirements___](#requirements)
* [___Installation___](#installation)
* [___Usage___](#usage)
* [___Examples___](#examples)
* [___License___](#license)
# Requirements
- [Vue.js](https://github.com/vuejs/vue) `2.x`
# Installation
```bash
# npm
$ npm install vue-underscore
```
# Usage
After using the plugin on main.js. You can call it simply with 'this.$_.findwhere' (each, map, reduce, filter...)
main.js
```javascript
import Vue from 'vue';
import underscore from 'vue-underscore';
import App from './App';
Vue.use(underscore);
new Vue({
...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.
```javascript
import {_} from 'vue-underscore';
let testArr = [{id: 1}, {id:2}];
let foundInfo = _.findWhere(testArr, {id:1});
```
# Examples
```html
export default {
methods: {
test () {
let testArr = [{id: 1}, {id:2}];
let foundInfo = this.$_.findWhere(testArr, {id:1});
}
}
}
```
# License
[The MIT License](http://opensource.org/licenses/MIT)