P粉2783794952023-08-18 13:12:55
你應該在你的程式碼中更改一些屬性 你寫的是 disabilityState 而不是 disabledState
<template> <button id="idDigitizePolygonBtn" class="clsDigitizePolygonBtn" :disabled="disabledState"> <slot name="slotDigitizePolygonBtnLabel">text</slot> </button> </template> <script> export default { setup(props) { return { disabledState: props.isDigitizePolygonBtnDisabled, }; }, props: { isDigitizePolygonBtnDisabled: { type: Boolean, required: true, default: false, }, }, }; </script>
在你的父元件中,你應該將 isDigitizePolygonBtnDisabled 屬性傳遞給子元件,而不是 disabledState。 對父元件進行的變更:
<template> <DigitizePolygonButton :isDigitizePolygonBtnDisabled="false"> <template v-slot:slotDigitizePolygonBtnLabel> <button>测试按钮</button> </template> </DigitizePolygonButton> </template>
進行這些更改應該可以正常工作。