typescript icon indicating copy to clipboard operation
typescript copied to clipboard

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

Open karimennassiri opened this issue 4 years ago • 1 comments

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

karimennassiri avatar Feb 09 '21 17:02 karimennassiri

@karimennassiri Could you provide a repository with the mentioned issue ? I'll be glad to help then :) If it's private you can send me a read-only access and revoke afterwards when I've found a solution.

kevinmarrec avatar Feb 21 '21 17:02 kevinmarrec