I'm using the example ga implementation from the nuxt official website
when I use import router from '~router'
and define router.afterEach
, I get this error:
[nuxt.js] Cannot load components TypeError: Cannot read property 'afterEach' of undefined
when I use const router = require('~router')
, I get this error:
[nuxt.js] Cannot load components TypeError: __webpack_require__(...) is not a function
Question: how to properly import router instance to get google analytics working?
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c743">#c743</a>)</em></sub></div>