简体   繁体   中英

How can I use vue-logger in the vuex store?

I cannot get vue-logger to work in my Vuex store file(s)

I would like to use vue-logger in my Vuex store file (and modules). However, I keep getting the error: "TypeError: Cannot read property 'info' of undefined" when I execute a statement like "Vue.log.info(....)" .

I had a similar problem with using "this.$http.get" in the store file, but that works now by using the "Vue.http.get" (as explained in this StackOverflow Answer ). However, " this.$log.info " does not work (for reasons obvious to me now, as in the store I am outside of the vue instance), but neither does "Vue.log.info" .

How can I use vue-logger in the store?

Try to use Vue.$log.info .

Notice the extra $ before log .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM