美文网首页
vue 中使用lodash

vue 中使用lodash

作者: mujiaxiansheng | 来源:发表于2017-07-13 13:21 被阅读1564次

转载自 https://stackoverflow.com/questions/37694243/using-lodash-in-all-of-vue-component-template

1 第一种方法

window._ = require('lodash');
不支持服务端渲染,服务端没有window

2 第二种方法

import lodash from 'lodash'
Object.defineProperty(Vue.prototype, '$lodash', { value: lodash });
或者
Vue.prototype.$lodash = lodash

相关文章

网友评论

      本文标题:vue 中使用lodash

      本文链接:https://www.haomeiwen.com/subject/txuwhxtx.html