我有一個 Vue.js 組件(名為 ),它接受一個道具(名為“輸入”);我正在嘗試傳遞在父組件中定義的方法(名為“normalizeInput”)的回傳值:
模板:
<div v-for="input in inputList" :key="input.id">
<dynamic-input :input="normalizeInput(input)" />
</div>
腳本:
methods: {
normalizeInput(input) {
//do something with input
return normalizedInput;
}
}
顯然這行不通;有沒有辦法實作這一目標?難道我做錯了什么?
我正在使用 nuxt v2.15.7
uj5u.com熱心網友回復:
您必須使用一個計算屬性,該屬性回傳一個以輸入為引數的函式:
computed: {
normalizeInput() {
return (input) =>{
return normalizedInput;
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/395498.html
下一篇:回傳從postgres獲取的串列
