N
N
Nikolai Tamazenko2020-09-05 18:56:22
Vue.js
Nikolai Tamazenko, 2020-09-05 18:56:22

When adding the v-if="isOwner" code, it should hide the button (edit the page) but it stopped loading for me?

When adding the v-if="isOwner" code, it should hide the button (edit page) for non-registered users, and this page stopped loading for me.
here is a link tohttps://vuevlad.web.app/ad/-MGDAVMNA5WOU44pMm2L

<template>
  <v-container>
    <v-layout row>
      <v-flex xs12>
        <v-card v-if="!loading">
          <v-img :src="ad.imageSrc" height="300px"></v-img>
          <v-card-text>
            <h1 class="text--primary">{{ad.title}}</h1>
            <p>{{ad.description}}</p>
          </v-card-text>
          <v-card-actions>
            <v-spacer></v-spacer>
            <addEditAdModal :ad="ad" v-if="isOwner"></addEditAdModal>
            <app-buy-modal :ad="ad"></app-buy-modal>
          </v-card-actions>
        </v-card>
        <div v-else class="text-xs-center">
          <v-progress-circular indeterminate :size="100" :width="4" color="purple"></v-progress-circular>
        </div>
      </v-flex>
    </v-layout>
  </v-container>
</template>

<script>
import EditAdModal from "./EditAdModal";

export default {
  props: ["id"],
  computed: {
    ad() {
      const id = this.id;
      return this.$store.getters.adById(id);
    },
    loading() {
      return this.$store.getters.loading;
    },
    isOwner() {
      return this.ad.ownerId === this.$store.getters.user.id;
    },
  },
  components: {
    addEditAdModal: EditAdModal,
  },
};
</script>

<style scoped>
.car-link {
  left: 90%;
  transform: translate(10%);
}
</style>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2020-09-05
@Niktam

5f53b63634a54141374464.png
Everything is written in the console

N
Nikolai Tamazenko, 2020-09-08
@Niktam

friends cheers, the answer was in adding this

isOwner() {
      let user = this.$store.getters.user;
      return user && this.ad.ownerId === this.$store.getters.user.id;
    },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question