Vue为@click事件添加条件

问题描述

我有一个Bootstrap崩溃,我想在打开崩溃时执行数据提取,但在关闭崩溃时不执行。因此,我需要检查@login_required def change_position(request,ptf,symbol): Securities = SecuritiesAHT if ptf == 'aht': Securities = SecuritiesAHT if ptf == 'svr': Securities = SecuritiesSVR security = Securities.objects.get(pk=symbol) ... 属性

我不确定这是否是一种好方法,因为它将始终在关闭和打开时执行提取

lstLines

解决方法

您可以在fetch方法中使用逻辑来检查数据是否已加载。将新字典添加到data()并将详细信息添加到fetchedData

data() {
  return {
    fetchedData: {}
  }
},methods: {
   fetch: function(id) {
       if(this.fetchedData[id]) {
          return this.fetchedData[id];
       } else {
          // call to fetch the data and add those details to the dictionary fetchedData
          this.fetchedData[id] = response.data;
       }
   }
}