您当前的位置: 首页 > 

@大迁世界

暂无认证

  • 3浏览

    0关注

    739博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

02. 将参数props限制在一个类型的列表中

@大迁世界 发布时间:2022-07-24 11:58:08 ,浏览量:3

这节课,我们来看下,怎么将一个 props 限制在一个特定的值的集合中。

假设,我们有一个 Image 组件,内容如下:


  



import { ref, computed } from 'vue'

const props = defineProps({
  imgStyle: {
    type: String,
    default: 'square',
  },
})

const computeImgStyle = computed(() => {
  return {
    square: props.imgStyle === 'square',
    rounded: props.imgStyle === 'rounded',
  }
})



.image {
关注
打赏
1664287990
查看更多评论
立即登录/注册

微信扫码登录

0.0387s