1

How to pass attributes to vuecomponent in vue router?

const routes = [
    {
        path: "/dashboard/profile",
        name: "DashboardProfile",
        component: <DashboardProfile foobar="false"/>, // <--- How can I achieve this?
    },
];

1 Answer 1

3

You could pass a prop object like :

const routes = [
    {
        path: "/dashboard/profile",
        name: "DashboardProfile",
        component: DashboardProfile,
        props:{show:false}
    },
];

then inside your component use that prop for conditional rendering at the component root.

Sign up to request clarification or add additional context in comments.

3 Comments

I just want to know if it's even possible to pass attributes to the view component.
You couldn't do that in that way, you could not instantiate the component using <></>
could you provide a real code ? because that is not possible <DashboardProfile foobar="false"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.