我正在根据条件渲染两个文本,并且能够根据条件将方法传递给单击事件。默认文本为 ADD TO COLLECTION,因为最初 hasPaid 属性为 false。付款后,我想将该属性设置为 true
addToCollection函数首先打开一个modal,在modal上,实现handlePayment函数。我已经能够有条件地渲染 div 以使用 v-on="" 显示添加到收藏或下载。我还从 handlePayment 函数返回 hasPaid 属性。
<div class="float-right peexo-faded-text card-inner-text" :face="face" v-on="!hasPaid ? {click: addToCollection} : {click: handleDownload(face)}">
{{!hasPaid ? 'ADD TO COLLECTION': 'DOWNLOAD' }}
</div>
data: function () {
return {
hasPaid: false,
}
},
addToCollection(){
this.showcollectionModal = true;
},
handlePayment(){
this.showcollectionModal = false;
let accept = true;
this.showpaymentsuccessmodal = true;
//this.hasPaid = true;
return {
hasPaid: accept
}
},
我希望能够在 handlePayment 函数上设置 hasPaid 属性,以便渲染函数选择它,以便 handleDownload 函数可以工作。