1

how can i pass the userid/uid along with the profile link (route: '/u/' + this.$auth.user.id) ? What i have below doesn't work.

my code is as follows (using nuxt)

<script>
import profilePic from './profilePic';

export default {
  components: { profilePic },

  data: () => ({
    links: [
      {
        icon: 'mdi-account-circle-outline',
        title: 'Profile',
        route: '/u/' + this.$auth.user.id
      },
      { icon: 'mdi-clipboard-multiple-outline', title: 'My Lists', route: '/' },
      { icon: 'mdi-logout', title: 'Logout', route: '/u/logout' }
    ]
  })
</script>
Phil
  • 157,677
  • 23
  • 242
  • 245
dishguy
  • 11
  • 2
  • can you elaborate what you mean by *not working*? is the route link `/u/undefined`? – Daniel Aug 25 '20 at 21:23
  • 1
    change `data: () => ({})` to `data () {}`. You will encounter wrong context issue if uses arrow function. – Sphinx Aug 25 '20 at 22:23
  • @Daniel, i get this error "TypeError Cannot read property '$auth' of undefined" – dishguy Aug 25 '20 at 23:39
  • @Sphinx, i updated it to be `data () { code },` but i get 2 errors 80:5 error Unexpected labeled statement *no-labels 80:12 error Expected an assignment or function call and instead saw an expression *no-unused-expressions – dishguy Aug 25 '20 at 23:43
  • @dishguy you need to change it to `data () { return { links: ... } }`. Alternatively, use `data: vm => ({ links: ... })` but use `vm.$auth.user.id` – Phil Aug 26 '20 at 01:31

0 Answers0