我想在計算屬性中獲取插槽道具。目前我將插槽道具傳遞給一個方法,它作業正常。但我想與v-model. 我可以這樣做嗎?
// MediaSelect.vue
<template>
<input-wrapper v-slot="slotProps">
<gallery-list
:value="getValue(slotProps.language)" // current
v-model="myValue" // I want
>
</gallery-list>
</input-wrapper>
</template>
<script>
export default {
computed: function(){
myValue: {
set: function(value){
this.$emit("input", value);
},
get: function(){
// I want to get slotProps in here, like this
return this.getValue(this.slotProps.language)
}
}
},
methods: {
getValue: function(language){
...
},
}
}
</script>
uj5u.com熱心網友回復:
不,這是不可能的,您不能將引數傳遞給計算屬性(這就是方法的用途)。
你應該這樣做:
<input-wrapper v-slot="slotProps">
<gallery-list
:value="getValue(slotProps.language)"
@input="$emit('input', $event)"
>
</gallery-list>
</input-wrapper>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/432657.html
