No.1 解析变量名msgs里面的内容:guardian2022
<script setup lang="ts"> const msgs:string='guaridna2022' </script> <template> <div> {{msgs}} </div> <HelloWorld msg="Vite + Vue" /> </template> <style scoped> </style>
打印: guardian2022
No.2 三元运算表达式:
<script setup lang="ts">
const msg:number = 1
</script>
<template>
{{msg ? 'I No1' : 'I No2'}}
</template>
<style scoped>
</style>
打印:I No1
<script setup lang="ts">
const msg:number = 0
</script>
<template>
{{msg ? 'I No1' : 'I No2'}}
</template>
<style scoped>
</style>
打印:I No2
No3.调用API的json类型
<script setup lang="ts">
const message:string = "100,200,300,400,500,600"
</script>
<template>
{{ message.split(',').map(v=> `¥${v}`) }}
</template>
<style scoped>
</style>
打印:[ "¥100", "¥200", "¥300", "¥400", "¥500", "¥600" ]