'Nuxt.js changing code from 'static' target to 'server' target
I have a nuxt2 project with target:'static'. It´s working very well.
Now, I´d like to change to target:'server' and ssr:true.
I have a plugin(in plugin folder) with this code:
export default (ctx, inject) => {
const bus = new Vue()
inject('bus', bus)
}
In my default.vue, I have this code:
// default.vue
created() {
this.$bus.$on('novo_preatend', (arg) => {
....
})
When I execute 'npm run dev' I get an error:
TypeError
Cannot read properties of undefined (reading '$on')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|