如何解决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;
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。