Search code examples
vue.jsvue-routershopwareshopware6

Set params to Shopware Navigation Path


The first page I call up in my Shopware 6 plugin should have a standard ID over the Vue Router.

routes: {
        list: {
            path: 'list/:id',
            component: 'plugin-list'
        },
    },

    navigation: [{
        id: 'plugin-list',
        label: 'Plugin',
        path: 'plugin.index.list/1',
        icon: 'default-shopping-paper-bag-product',
        parent: 'sw-catalogue',
        position: 100
    }]

The error that is passed by Vue Router is this: [vue-router] Route with name 'plugin.index.list/1' does not exist

and the Component gets the wrong route. The route itself works without the parameters.

Thanks

I've already tried to pass the route as an array in the navigation, like 'path: 'plugin.index.list/{id: 1}', or to specify that as a separate parameter in the navigation.

    navigation: [{
        id: 'plugin-list',
        label: 'Plugin',
        path: 'plugin.index.list',
        params: 'id: 1'
        icon: 'default-shopping-paper-bag-product',
        parent: 'sw-catalogue',
        position: 100
    }]

Solution

  • params should be an object.

    navigation: [{
        id: 'plugin-list',
        label: 'Plugin',
        path: 'plugin.index.list',
        params: {
            id: '1'
        },
        icon: 'default-shopping-paper-bag-product',
        parent: 'sw-catalogue',
        position: 100
    }]