I am facing an issue where I provide variables in a component and then try to inject/change them in the child component. Surprisingly, this setup works perfectly fine on the local server but once uploaded to the live server, the variable doesn't seem to update.
I am utilizing the composition API for this project.
Parent Component A
import { provide, ref } from 'vue';
const loggedIn = ref(false);
provide('global', loggedIn);
const credentials = ref(true);
provide('credentials', credentials);
Child Component B
<script setup lang="ts">
import {
IonContent,
IonHeader,
IonPage,
IonTitle,
IonToolbar,
} from "@ionic/vue";
import router from "@/router";
import { inject, ref } from "vue";
const global: boolean = inject("global") as boolean;
const credentials: boolean = inject("credentials") as boolean;
function greet(global: boolean, credentials: boolean) {
const usr = document.querySelector("input[name=email]").value;
const pass = document.querySelector("input[name=password]").value;
if (
usr === "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5433213127201433213127207a373b39">[email protected]</a>" &&
pass === "guest123#"
) {
this.global = true;
this.credentials = false;
router.push("/app");
}
}
</script>
Both 'this.global = true' and 'this.credentials = false' are triggering warnings in VS Code:
'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)
HomePage.vue(19, 10): An outer value of 'this' is shadowed by this container.
Any suggestions or ideas on how I can resolve this particular issue?