简体   繁体   中英

i Get a "Property type does not exist on type boolean" error when i try to do an inline ternary operator in vue3 typescript

The error Property type does not exist on type boolean shows on the show.value boolean

when I try to apply the text for the icon based on the 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>

You should use show instead of show.value in your template. show.value is only available within the script tag in the composition api.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM