Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New routes resulting in 404 #64

Closed
paragonsoftwaresolutions opened this issue Aug 13, 2019 · 6 comments
Closed

New routes resulting in 404 #64

paragonsoftwaresolutions opened this issue Aug 13, 2019 · 6 comments

Comments

@paragonsoftwaresolutions

I am trying to implement a "Create" and "Edit" button that will open the desired page. I set the routes up the same as it is done in the admin routes file for articles/create and articles/edit. However, when I click on the button I get a 404 response. I am not seeing a route set up for articles/create yet it still works. Am I missing something here?

Here is my router module:
`import Layout from '@/layout';

const productsRoutes = {
path: '/products',
component: Layout,
redirect: '/products/catalog',
name: 'Products',
alwaysShow: true,
meta: {
title: 'Products',
icon: 'shopping',
permissions: ['view menu products'],
},
children: [
{
path: 'catalog',
component: () => import('@/views/products/List'),
name: 'Catalog',
meta: { title: 'Catalog', icon: 'list', noCache: true },
},
{
path: 'products/create',
component: () => import('@/views/products/Create'),
name: 'CreateProduct',
meta: { title: 'createProduct', icon: 'edit', permissions: ['manage products'] },
hidden: true,
},
{
path: 'products/edit/:id(\d+)',
component: () => import('@/views/products/Edit'),
name: 'EditProduct',
meta: { title: 'editProduct', noCache: true, permissions: ['manage products'] },
hidden: true,
},
],
};

export default productsRoutes;`

Here is the code for the button to open the page:
<router-link :to="'/products/edit/'+row.id"> <el-button type="primary" size="small" icon="el-icon-edit" v-permission="['manage products']"> Edit </el-button> </router-link>

@tuandm
Copy link
Owner

tuandm commented Aug 14, 2019

@paragonsoftwaresolutions Have you added productsRoutes to your router/index.js? There are some examples in Laravue that you can use as references - like user, article.

@paragonsoftwaresolutions
Copy link
Author

Yes, it is there. I can access Catalog page, but I can not access the create or edit page.

@tuandm
Copy link
Owner

tuandm commented Aug 16, 2019

@paragonsoftwaresolutions

path: 'products/edit/:id(\d+)',

I think this should be \\d because you are using single quote.

@paragonsoftwaresolutions
Copy link
Author

I have tried it that way. Same results. I can't access the create page either.

@paragonsoftwaresolutions
Copy link
Author

I figured out what I was doing wrong. I removed products/ from my edit route and now it works. I'm assuming since the parent route path was '/products' having that on my child route meant I was trying to access '/products/products/edit' which doesn't exist.

@tuandm
Copy link
Owner

tuandm commented Aug 27, 2019

@paragonsoftwaresolutions Thanks for letting me know. I'm sorry because I couldn't help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants