i'm new in Vue.js, so there are concepts that maybe i'm missing. The thing is that i've been trying to do this for months, but i couldn't get a solution. What i'm trying to do is change the message of a v-alert but on another js script, importing the variable of said message and changing it.
This is a piece of my App.vue
<v-app>
<v-alert transition="scale-transition" :type="success" max-width="280" height="55" class="justify-center">{{alert.message}}</v-alert>
...
I have this declared variables on appController.js
export default{
data () {
return {
alert:{
visible: true,
type: "success",
message: "test"
}
What i'm trying to do is getting that variables on another js script, so i can modify it like this thing i did on loginController.js
import {alert} from './appController.js';
export default {
methods: {
loginFunc() {
//When i call loginFunc, content of var message changes to "Test 2"
alert.message = "Test 2";
}
}
}
But when i call loginFunc from a v-btn, i get these errors on console:
vue.runtime.esm.js?c320:619 [Vue warn]: Error in v-on handler: "TypeError: Cannot set properties of undefined (setting 'message')"
TypeError: Cannot set properties of undefined (setting 'message')
What i am doing wrong? What can i do to solve that and change content of var message, so i can show it on the v-alert?