Skip to content

this.$nuxt.refresh not recognized while using property decorator #485

@karimennassiri

Description

@karimennassiri

Describe the bug
I'm usingnuxt-property-decorator and vue-property-decorator to import elements such Vue, Component, Model, ect into my project. I chose to develop usingClass-Based Component .
Inside a page (Home), I created a method that allows to perform an operation followed by a page refresh using this.$nuxt.refresh() I manage to refresh the page, however I have a warning that tells me that my instruction is not recognized.
`Property '$nuxt' does not exist on type 'Home'.
I exactly followed what is here : https://typescript.nuxtjs.org/guide/setup to install my Nuxt project with TS. The problem remains the same.

To Reproduce
PS: the code has been clipped to keep the important part

<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
import { manager } from '../services/manager'

@Component({})
export default class Home extends Vue {
  services!: Array
  async asyncData() {
    const services = await manger.get()
    return { services }
  }

  ....

  /**
   * Change results order
   * @param value {string}
   * @returns {void}
   */
  refreshResults(value: string): void {
    // Setting the new ranking value
    manager.setSettings(`${value}(name)`)
    // refreshing page
    this.$nuxt.refresh()
  }
}

Expected behavior
this.$nuxt.refresh() to be recognized

Screenshots
https://i.stack.imgur.com/c7nlJ.png

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions