N
N
Nayob2020-09-29 09:11:21
Vue.js
Nayob, 2020-09-29 09:11:21

Why doesn't computed work in v-if?

There is a component:

<template lang="pug">
nav(v-if="showNav")
  .nav-wrapper
    ul#nav-mobile.left.hide-on-med-and-down
      li
        a(href="/") Home
      li
        a(href="/about") About
</template>

<script>
export default {
  сomputed: {
    showNav: function() {
      return this.$store.getters.isAuthenticated;
    },
  }
}
</script>


in the browser console the following warn:
[Vue warn]: Property "showNav" was accessed during render but is not defined on instance. 
  at <Navbar onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > > 
  at <RouterView> 
  at <App>

Can anyone suggest a direction in which to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Borutkin, 2020-09-29
@Atanvar

Why did you make another computed property for a computed property?
just try
...mapGetters(['isAuthenticated'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question