The globalProperties property of app.config is not defined and cannot be read

When attempting to register a global filter in Vue3, an error is being raised:

main.js?56d7:13 Uncaught TypeError: Cannot read property 'globalProperties' of undefined

Despite referencing the solution provided in Use filter in Vue3 but can't read globalProperties, the issue persists.

import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./assets/tailwind.css";
import axiosSetUp from "@/auth/axiosSetUp";
import {formatIsoDateTime as utils_formatIsoDateTime} from "@/utils";

axiosSetUp()
const app = createApp(App).use(store).use(router).mount("#app");


app.config.globalProperties.$filters = {
    formatIsoDateTime(isoString) {
        return utils_formatIsoDateTime(isoString)
    }
}

Any insights on where the problem might be located?

Answer №1

Separating the root instance from the root component is recommended:

const application = createApp(App).use(store).use(router);

// Utilize the root instance to implement your configurations
application.config.globalProperties.$filters = {
    formatIsoDateTime(isoString) {
        return utils_formatIsoDateTime(isoString)
    }
}
// Finally, mount it 
application.mount("#app")

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is jQuery Autocomplete functioning properly on outdated browsers, but not on newer ones?

Here is the JSON data I have for my auto complete feature { "list" : [ { "genericIndicatorId" : 100, "isActive" : false, "maxValue" : null, "minValue" : null, "modificationDate" : 1283904000000, "monotone" : 1, "name":"Abbau", ...

Learn the process of passing Laravel route parameters to Vue components

As a newcomer to Vue, I've spent a lot of time searching on Google but haven't been able to find a solution that fits my current situation. I'm not sure how to pass a route into a Vue component. Is there a way to do this in Laravel, specific ...

Node.js Objects and String Manipulation

Within my nodeJS scenario, I am working with an object that includes both elements and an array of items: var Obj = { count: 3, items: [{ "organizationCode": "FP1", "organizationName": "FTE Process Org" }, { "organizationCode ...

What is the best way to toggle between different sections of a webpage using HTML, CSS, and Javascript?

I am looking to display unique content based on the user's selection of different month/year options on the same page. For example, if the user chooses March 2021, I would like to show them events specific to that month. Here is a screenshot for refer ...

Wrapper component for VueJS version 2.4, providing essential functionality

I find myself struggling to create a basic wrapper component around a select element in Vue. Here is an example of what I currently have: <select v-model="foo" name="bar" v-validate="'required'" v-bind:class="{ invalid: errors.has('bar&a ...

Increasing a browser's JavaScript authorization level?

I am currently developing an internal tool and I have a vague memory of a method to prompt for elevated permissions in scripts, allowing cross-site requests if approved. Given that this tool is meant for internal use, this feature could potentially solve a ...

Guide to finding your way to a specific section in React

I attempted to navigate to a particular section within a page. I also tried to include an id in the component, but it didn't function as expected <Login id ="login_section > ...

Tips for sending a form with the <button type="submit"> element

I created a login form and initially used <button type="submit">, but unfortunately, it was not functioning as expected. However, when I switched to using <input type="submit">, the form submission worked perfectly. Is there a JavaScript method ...

Sending a cookie token to the server through the header

This is my first attempt at working with a server Utilizing React and express Storing token in browser cookie from the server //Upon login request res.cookie('token', token, {maxAge: 3600000} ).json({ user: userDoc, message: 'message!&apos ...

What could be the reason for the variable not being defined?

Initially, I have the following function: $.getJSON( 'getTerminalinsideCircle.json', { centerLatitude: adressMarker.getPosition().lat(), centerLongitude: ...

What is the procedure for assigning an element's background-color to match its class name?

Is there a way to use jQuery to make the background color of a span element match its class? $(function() { $("span").css("background-color") }); span { display: inline-block; width: 5px; height: 5px; border: solid #0a0a0a 1px; } <script src= ...

simplified code - toggle section visibility

$(".link1").click(function(){ $(".slide2, .slide3, .slide4, .slide5").css("opacity", 0.0); $(".slide1").fadeTo("slow", 1.0); }); $(".link2").click(function(){ $(".slide1, .slide3, .slide4, .slide5").css("opacity", 0.0); $(".slide2").fadeTo("slow" ...

Looking to learn more about utilizing the spread operator with an object?

Seeking a more efficient way to assign my state object to the data returned from a REST API in my reactJS application. Wondering if utilizing a spread operator could simplify the process? state = { recordid: "", companyname: {val:"",err:"" ...

Rendering lists in Vuejs2 with computed properties for filtering

I'm struggling with list rendering and filtering data using computed properties. Instead of statically setting the row.age value, I want to filter based on filterKey. Any guidance on how to achieve this? I'm having trouble understanding it. He ...

What could be the reason behind the error message stating that the Vue JS method function "validEmail

An error is generated by the validEmail function that says "error 'validEmail' is not defined" <script> export default { data() { return { accountEmail: "", accountEmailVerify: "" }; }, methods: ...

Angular 6 and the intricacies of nested ternary conditions

I need help with a ternary condition in an HTML template file: <div *ngFor="let $m of $layer.child; let $childIndex=index" [Latitude]="$m.latitude" [Longitude]="$m.longitude" [IconInfo]="$childIndex== 0 ? _iconInfo1:$c ...

Error: The variable "message" has not been defined. Please define it before displaying the welcome

While I was experimenting with my welcome message and attempting to convert it into an embed, I ended up rewriting the entire code to make it compatible. However, upon completion, I encountered the error message is not defined. var welcomePath = './ ...

Using async/await in a POST handler within Express.js

My goal is to invoke an async function within a POST handler. The async function I'm trying to call looks like this (the code is functional): const seaport = require("./seaport.js"); // This function creates a fixed price sell order (FPSO) ...

Adjust the quantity of divs shown depending on the value entered in a text input field

It seems like I am on the right track, but there is something simple that I am missing. I'm currently utilizing the jQuery knob plugin to update the input field. $('document').ready(function() { $(".knob").knob({ c ...

Numerous applications collaborating on workflows within a Firebase project

I am planning to create multiple Progressive Web App (PWA) sites under a single Firebase project. The idea is to make them accessible through different subdomains like app1.domain.com, app2.domain.com, and app3.domain.com. Even though these apps are conce ...