admin管理员组

文章数量:1398806

I'm trying to register global filter in Vue3 but it raises this error:

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

According to the Use filter in Vue3 but can't read globalProperties it should work.

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)
    }
}

Do you know where the problem is?

I'm trying to register global filter in Vue3 but it raises this error:

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

According to the Use filter in Vue3 but can't read globalProperties it should work.

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)
    }
}

Do you know where the problem is?

Share Improve this question asked Jun 25, 2021 at 14:50 MilanoMilano 18.8k47 gold badges172 silver badges386 bronze badges 2
  • 1 I was just answering the Docker question! Essentially, you have a SQL injection situation because (, ! and ) have special meaning in an ODBC connection string. – Panagiotis Kanavos Commented Jul 8, 2021 at 12:40
  • @PanagiotisKanavos Oh, thank you. I used the SQLAlchemy and it worked so I've deleted it and I can't find the URL so I can't undelete it. – Milano Commented Jul 8, 2021 at 13:40
Add a ment  | 

1 Answer 1

Reset to default 7

You should separate the root instance from the root ponent :

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

//use the root instance to add your config
app.config.globalProperties.$filters = {
    formatIsoDateTime(isoString) {
        return utils_formatIsoDateTime(isoString)
    }
}
// then you could mount it 
app.mount("#app")

本文标签: javascriptappconfigglobalPropertiesCannot read property 39globalProperties39 of undefinedStack Overflow