Last active
September 27, 2018 02:14
-
-
Save guzhenhuaGitHub/d02d8040a521e222b5bb488b1d543dba to your computer and use it in GitHub Desktop.
add lodash functions to Vue.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
/* 将Lodash的方法注入到Vue的filter中 */ | |
_.each(_, (v, k) => { | |
if (_.isFunction(v)) { | |
Vue.filter('_' + k, (input, args) => { | |
return v.apply(_, _.flatten([[input], args])) | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment