美文网首页
如何在Vue.js中使用lodash库

如何在Vue.js中使用lodash库

作者: 630d0109dd74 | 来源:发表于2018-07-05 00:23 被阅读0次

lodash npm 或 yarn 安装。

$ npm install lodash --save

$ yarn add lodash

只要在 Vue.js类中引用库后,就可调用其方法。

实例如下

Click me as fast as you can!import _ from 'lodash'export default { methods: { throttledMethod: _.throttle(() => { console.log('I get fired every two seconds!') }, 2000) }} Click me as fast as you can!import _ from 'lodash'export default { methods: { throttledMethod: _.throttle(() => { console.log('I get fired every two seconds!') }, 2000) }} Click me as fast as you can!import _ from 'lodash'export default { methods: { throttledMethod: _.throttle(() => { console.log('I get fired every two seconds!') }, 2000) }} Click me as fast as you can!import _ from 'lodash'export default { methods: { throttledMethod: _.throttle(() => { console.log('I get fired every two seconds!') }, 2000) }}import _ from 'lodash'

export default {

  methods: {

    throttledMethod: _.throttle(() => {

      console.log('I get fired every two seconds!')

    }, 2000)

  }

}

相关文章

网友评论

      本文标题:如何在Vue.js中使用lodash库

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