我正在使用此代碼
<v-list-item>
<v-btn
@click="onDownloadFile(document)"
:disabled=getFileExtention
>Download as pdf</v-btn
>
</v-list-item>
其中 getFileExtention 回傳布林值
getFileExtention() {
//console.log(this.document.extension==="pdf");
return this.document.extension === "pdf";
}
但它不起作用,仍然說 [Vue 警告]:無效的道具:道具“禁用”的型別檢查失敗。預期布林值,得到 Function 。請幫忙
uj5u.com熱心網友回復:
定義getFileExtension為計算屬性:
computed:{
getFileExtention() {
//console.log(this.document.extension==="pdf");
return this.document.extension === "pdf";
}
}
然后像這樣使用它 :disabled="getFileExtention"
uj5u.com熱心網友回復:
您需要定義getFileExtention 為methods這一點。
methods:{
getFileExtention() {
return this.document.extension === "pdf";
}
}
但是如果你想要基于reactive依賴的快取能力,你也可以使用computedproperty
computed:{
getFileExtention() {
return this.document.extension === "pdf";
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/346182.html
標籤:javascript Vue.js vuetify.js
