記錄使用uniapp開發項目時使用slot插槽情況下小程序編譯報錯的問題:Errors compiling template:目前僅支持解構插槽 otherSlotProps,如 v-slot="{ user }"


出現問題:Errors compiling template:目前僅支持解構插槽 otherSlotProps,如 v-slot="{ user }"

1.子組件中 test.vue

    <view >
        <slot name="other" :user="user"></slot>
        <slot></slot>
    </view>

2.在父組件使用

        <test>
            <template v-slot:other="otherSlotProps">
                {{ otherSlotProps.user.lastName }}
            </template>
        </test>

此時在編譯到微信小程序中報錯

 

 

 而運行到其他環境下比如H5是沒問題的

那么在微信小程序中要使用解構插槽方式實現:

        <test>
            <template v-slot:other="{user}">
                {{ user.lastName }}
            </template>
        </test>

此時運行是沒問題的,參數傳值也沒問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM