【Vue】属性计算 computed

<script setup>
  import { ref,computed} from 'vue' 
  let hbs = ref([]); //装爱好的值
  const publishHbsMessage=computed(()=>{
    return hbs.value.length>0?'Yes':'No'
  })
script>

<template>
  <div><input type="checkbox" name="hbs" v-model="hbs" value=""><input type="checkbox" name="hbs" v-model="hbs" value=""><input type="checkbox" name="hbs" v-model="hbs" value=""><input type="checkbox" name="hbs" v-model="hbs" value="">
    <br>
    {{ hbs }}
    <br>
    {{ publishHbsMessage }}
  div>
template> 

<style scoped>

style>

你可能感兴趣的:(Vue,vue.js,javascript,前端)