I
I
Igor Myasnikov2020-01-23 09:27:04
Vue.js
Igor Myasnikov, 2020-01-23 09:27:04

Why are dynamic pages not updating?

Good afternoon
There is a dynamic component post/_slug.vue

_slug.vue

<template lang="pug">
  .inner-wrapper
    <Breadcrumbs :labels="labels"/>
    main.main#content
      Article
        template(v-slot:title)
          h1.article__title {{ post.title }}
        template(v-slot:toc v-if="post.toc")
          Toc(:data="post.toc")
        template(v-slot:text)
          .article__text
            .container(v-html="post.text")
</template>

<script>
import Breadcrumbs from '@/components/sections/breadcrumbs';
import Article from '@/components/sections/article';
import Table from '@/components/table';
import Toc from '@/components/toc';

export default {
  validate({params}) {
    return Boolean(params.id);
  },
  data() {
    return {
      post: {},
    };
  },
  components: {
    Breadcrumbs,
    Article,
    Table,
    Toc,
    Gallery: () => import('vue-easy-lightbox'),
  },
  computed: {
    labels() {
      return {
        last: this.post.title,
      };
    },
  },
  async created() {
    const query = `
      query Articles($id: ID!) {
        article(id: $id) {
          title
          descr
          keywords
          slug
          text
        }
      }
    `;

    const responce = await this.$axios.$post(URL, {
      query,
      variables: {
        id: this.$route.params.id,
      },
      headers: {
        'content-type': 'application/json',
      },
    });

    this.post = responce.data.article;
  },
};


When you go to it from any page, everything works, but when you refresh the page, a 404 error occurs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Athanor, 2020-01-23
@Athanor

Who is throwing a 404 error? vue-router or your server? If the latter, then you need to either enable hash-mode in your vue-router, or make the server return index.html for all requests except api

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question