簡體   English   中英

Vue不會更新生產模式下API調用加載的組件prop,但是在開發中

[英]Vue doesn't update component prop loaded by API call in production mode but does in development

我有一個包裝器組件,它為子控件提供API調用並存儲結果,以及一個列表組件,顯示通過prop傳遞的請求項。 問題是它在開發模式下顯示它們但在生產中沒有,盡管在兩種情況下API調用都沒問題並且響應是正確的。

我在同一環境中運行這兩種模式。 看起來像一個反應性問題。

這是一個模板代碼:

<vue-api>
  <vue-list-filter-synchronizer slot-scope="{ result, getPrograms }"
                                ...
                                @params-updated="getPrograms">
     ...
     <div class="content">
        <vue-list :items="result ? result.data : []"
                  .../>
     </div>
  </vue-list-filter-synchronizer>
</vue-api>

VueAPI組件:

const VueAPI = {
  data() {
    return {
      result: null,
      error: null,
      loading: false
    }
  },
  ...
  methods: {
    getPrograms(params) {
      this.query(services.getPrograms)([params]);
    },
    query(f) {
      return (args=[]) => {
        if (!this.loading) {
          this.loading = true;
          f(...args)
            .then(({ data }) => this.result = data)
            .catch(error => this.error = error)
            .finally(() => this.loading = false);
      }
    }
  },
  render() {
    return this.$scopedSlots.default(this.slotScope);
  }
}

我希望result.data在VueAPI組件將被顯示為研發和生產模式列表中的項目,但它只能在發展模式是如此。

首先,我的vue.debug.js有一個舊版本,所以它適用於它,並沒有沒有。 當我更新它時,問題也出現在調試模式中。 其次,問題是我對slot-scope使用了一種不推薦的語法。 當我將其更改為v-slot語法時,一切都按預期開始工作。

暫無
暫無

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

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