Created
May 10, 2017 18:18
-
-
Save unr/1ade4b702af5d818f37aee872793e7ba to your computer and use it in GitHub Desktop.
Worlds most simple Vue Plugin for Lodash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
import VueLodash from './vue-lodash.js'; | |
Vue.use(VueLodash); | |
// On components, you'll now have access to | |
this._.filter(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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