当我尝试在 vue3 打字稿中执行内联三元运算符时,我收到"Property type does not exist on type boolean"错误



错误Property type does not exist on type boolean节目上的节目。布尔值

当我尝试基于truthiness

为图标应用文本时
<template>
<div class="d-flex cursor-pointer justify-content-between border rounded bg-white mt-4 p-2 w-100 " @click="dropdown">
<span>Purchase Requsition</span>
<span class="material-icons fs-28 text-primary">
{{show.value ? 'arrow_circle_down' : 'arrow_circle_down' }}     </span>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
const show = ref<boolean>(false)
function dropdown(){
show.value = !show.value
}
</script>
<style scoped>
</style>

您应该在模板中使用show而不是show.valueshow.value仅在合成api的script标签中可用。

<template>
<div class="d-flex cursor-pointer justify-content-between border rounded bg-white mt-4 p-2 w-100 " @click="dropdown">
<span>Purchase Requsition</span>
<span class="material-icons fs-28 text-primary">
{{show ? 'arrow_circle_down' : 'arrow_circle_down' }}
</span>
</div>
</template>

相关内容

最新更新