繁体   English   中英

当我尝试在 vue3 打字稿中执行内联三元运算符时,出现“布尔类型上不存在属性类型”错误

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

错误Property type does not exist on type boolean显示在 show.value boolean

当我尝试根据真实性为图标应用文本时

<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.value show.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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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