No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Using global lodash with quasar v15 (Solved)

    Help
    5
    8
    5787
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jeimz173 last edited by Max

      Hi guys, newbie here i need some help on how to import lodash and use it globally?

      I followed the instructions on how to install some package as plugins but I think I’m missing something.

      here is my code:

      //plugins>lodash.js
      
      
      // here I import the lodash and use it on Vue
      
      import lodash from 'lodash'
      // leave the export, even if you don't use it
      export default ({ app, router, Vue }) => {
        Vue.use(lodash)
      }
      

      but then when i tested out some examples of lodash( like _.chunk(['a', 'b', 'c', 'd'], 2)) to my VUE file ,it says, …error ‘_’ is not defined to my cli

      it fails me… please help me thank you!

      1 Reply Last reply Reply Quote 0
      • rstoenescu
        rstoenescu Admin last edited by rstoenescu

        lodash is not a vue package, so it makes no sense to Vue.use(lodash).

        Pick one of these two scenarios:

        1. “I want it globally available in vue files”
        import lodash from 'lodash'
        
        export default ({ Vue }) => {
          Vue.prototype.$_ = lodash // then use as this.$_
        }
        
        1. “I want to globally use it, but not through Vue”
          Simply import it in any file (js, vue) and then use the reference to it.
        1 Reply Last reply Reply Quote 3
        • J
          jeimz173 last edited by

          Hi @rstoenescu thank you! i picked the first scenario 🙂

          1 Reply Last reply Reply Quote 0
          • H
            hannesl last edited by hannesl

            Hi, I am new to quasar and trying as well to add a javascript (log4javascript) and actually I don’t know where exactly to put the lines @rstoenescu . Tried with App.vue but gives error:

            ERROR in ./src/App.vue?vue&type=script&lang=js (./node_modules/babel-loader/lib??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js)
            Module build failed:   SyntaxError: /development/proj/frontend.q/src/App.vue: Unexpected token, expected ";" (9:25)
                 7 | 
                 8 | import log4javascript from 'log4javascript'
              >  9 | export default ({ Vue }) {
                   |                          ^
                10 |   name: 'App',
                11 |   Vue.prototype.$log = log4javascript // then use as this.$_
                12 | }
            

            Could you pls guide me? Thanks and regards

            rstoenescu 1 Reply Last reply Reply Quote 0
            • rstoenescu
              rstoenescu Admin @hannesl last edited by

              @hannesl https://quasar-framework.org/guide/app-plugins.html

              1 Reply Last reply Reply Quote 0
              • H
                hannesl last edited by

                @rstoenescu ok - thanks I did bring it to work, the term “plugin” was confusing me.

                1 Reply Last reply Reply Quote 0
                • T
                  turigeza last edited by turigeza

                  I ended up doing this in my plugin file. This makes it globally available.

                  // import something here
                  import _ from 'lodash';
                  
                  // leave the export, even if you don't use it
                  export default ({ app, router, Vue }) => {
                      window._ = _;
                  };
                  

                  And then add

                   globals: {
                      'ga': true, // Google Analytics
                      'cordova': true,
                      '$axios': true,
                      '_': true,
                      '__statics': true
                    },
                  

                  into .eslintrc.js. So the linter doesn’t complain. One has to restart quasar dev to reload the .eslintrc.js file.

                  After that one can use lodash as usual just by typing _.

                  1 Reply Last reply Reply Quote 0
                  • X
                    xfinity26 last edited by

                    It is possible to perform the second step (checking to find out what the purchase was made with your card) With this option you might be able utilize the information (date date, time, and place of purchase).https://sites.google.com/view/checkwalmartgiftcardbalance/
                    https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalance/
                    https://sites.google.com/view/homedepotgiftcardbalances/
                    https://sites.google.com/view/macysgiftcardbalance/
                    https://sites.google.com/egiftcard.website/targetcomcheckbalance/
                    https://sites.google.com/view/targetgiftcardbalancee/contact-us
                    https://sites.google.com/paypalloginus.com/paypal-login/
                    https://sites.google.com/ledgercomstarts.com/ledgercomstarts/
                    https://sites.google.com/view/venmol0gin/
                    https://sites.google.com/view/walmartgiftcardbalancecheckk/
                    https://sites.google.com/view/url-amazon-com-redeem/
                    https://sites.google.com/view/vanillagiftcardbalancee/
                    https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalance/
                    https://sites.google.com/vanillaegiftcardbalance.com/vanillaegiftcardbalance/
                    https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalancecheck/
                    https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalances/
                    https://amazoncomcode.onepage.website/
                    https://sites.google.com/ledgercomstarts.com/ledgercomstart/
                    https://sites.google.com/view/dunkindonutsgiftcardbalances/
                    https://sites.google.com/view/amazoncomredeemgift/
                    https://sites.google.com/view/url-amazoncom-mytv/
                    https://sites.google.com/view/amazon-redeem-canada/
                    https://sites.google.com/view/amazoncomredeemuk/
                    https://sites.google.com/mytargetgiftcardbalance.com/targetcomcheckbalance/
                    https://sites.google.com/mytargetgiftcardbalance.com/targetgiftcardbalance/
                    https://sites.google.com/view/sephoragiftcardbalance/
                    https://sites.google.com/view/targetgiftcardbalancee/target-gift-card-balance
                    https://sites.google.com/view/targetcomcheckbalance/
                    https://sites.google.com/gifrcard-balance.com/ebaygiftcardbalance/
                    https://sites.google.com/targetredcardslogin.com/targetredcardlogin/
                    https://sites.google.com/view/itunes-gift-card-balance/
                    https://sites.google.com/view/ebay-gift-card-balance/
                    https://sites.google.com/view/fandangogiftcardbalance/
                    https://sites.google.com/gifrcard-balance.com/bestbuygiftcardbalance/
                    https://sites.google.com/view/nikegiftcardbalance/

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post