簡體   English   中英

如何訪問方法中局部變量的狀態 - Vue?

[英]How to access the state of a local variable within a method - Vue?

如何訪問方法中局部變量的狀態 - Vue?

我需要為對話框設置一個值,以便我可以打開彈出窗口。

通過移植我想在加載后打開彈出窗口然后返回數據。

import { mapState, mapGetters, mapActions } from 'vuex'
export default {
  name: 'PageIndex',
  data () {
    return {
      dialog: false,
    }
  },
  methods: {
    ...mapActions('example', ['retrievePratica']),
    aulaPratica (tipo, aula) {
      var data = { 'tipo': tipo, 'aula': aula }
      this.retrievePratica(data).then(function () {
        this.$store.state.dialog = true    <------ Here
      })
    }
  }
}

通過使用箭頭功能,您可以通過this.dialog訪問本地數據dialog

this.retrievePratica(data)
  .then(() => {
    this.dialog = true
  })

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM