Skip to content

Instantly share code, notes, and snippets.

@unr
Created May 10, 2017 18:18
Show Gist options
  • Save unr/1ade4b702af5d818f37aee872793e7ba to your computer and use it in GitHub Desktop.
Save unr/1ade4b702af5d818f37aee872793e7ba to your computer and use it in GitHub Desktop.
Worlds most simple Vue Plugin for Lodash
import Vue from 'vue';
import VueLodash from './vue-lodash.js';
Vue.use(VueLodash);
// On components, you'll now have access to
this._.filter();
import _ from 'lodash';
const VueLodash = {
install(Vue) {
// prevent duplicate instance on SSR
if (!Vue.prototype._) {
Object.defineProperty(Vue.prototype, '_', { value: _ });
}
},
};
export default VueLodash;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment