美文网首页程序员
nuxt - 踩坑(一)安装lodash

nuxt - 踩坑(一)安装lodash

作者: 前端girl吖 | 来源:发表于2019-01-18 11:45 被阅读0次
    • 安装lodash

       yarn add lodash
      
    • 作为第三方插件引入

      //  plugins/lodash.js
      import _ from 'lodash'
      import Vue from 'vue'
      Vue.prototype.$lodash = _
      /* export default ({ app }, inject) => {
       inject('lodash', _)
      } */
      //这边只能vue页面使用
      
    • 若需要js文件里使用_ ,可在nuxt.config.js里配置

       build: {
          plugins: [
             new webpack.ProvidePlugin({
              _: 'lodash'
           })
         ]
      }
      
    赞赞哇.png

    相关文章

      网友评论

        本文标题:nuxt - 踩坑(一)安装lodash

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