当前位置:网站首页>02. 将参数props限制在一个类型的列表中
02. 将参数props限制在一个类型的列表中
2022-07-25 15:59:00 【@大迁世界】
这节课,我们来看下,怎么将一个 props 限制在一个特定的值的集合中。
假设,我们有一个 Image 组件,内容如下:
<template>
<img
class="image"
:class="computeImgStyle"
src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fnews.yxrb.net%2Fuploadfile%2F2021%2F0419%2F20210419103029168.jpg&refer=http%3A%2F%2Fnews.yxrb.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661221742&t=07639ae48c1b346e8beaca365ce0b1c1"
/>
</template>
<script setup>
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',
}
})
</script>
<style scoped>
.image {边栏推荐
- General test case writing specification
- 阿唐的小帮手
- 国债年化利率太低了,有比国债逆回购年化利率还要高的理财产品吗?
- Copy a word style template to another document
- 基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
- 没错,请求DNS服务器还可以使用UDP协议
- Lazy loading of pictures
- MySQL table write lock
- "Digital security" alert NFT's seven Scams
- Visual studio 2022 view class diagram
猜你喜欢
![Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]](/img/03/54a2d82a17cd07374dc0aedacd7b11.png)
Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]

Ice 100g network card fragment message hash problem

Redis distributed lock, it's really impossible without it

开发者如何为React Native选择合适的数据库

Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式

Crazy God redis notes 12

Equivalent change of resistance circuit (Ⅱ)

Exploration of 6-wire SPI transmission mode

Huawei 2023 starts to warm up in advance! Zuo Shen's program code interview guide comes in handy

Boomi荣获“多元化最佳首席执行官奖”和“职业成长最佳公司奖”,在大型公司类别中跻身50强
随机推荐
兆骑科创海内外高层次创新创业人才服务平台,双创成果转化平台
Basic usage of MFC thread afxbeginthread, passing multiple parameters
R语言偏相关性计算(Partial Correlation)、使用ggm包的pcor函数计算偏相关性(Partial Correlations)
Storage structure of cross linked list
leetcode:528. 按权重随机选择【普通随机失效 + 要用前缀和二分】
Lazy loading of pictures
R语言ggplot2可视化线图(line)、自定义配置标题文本相关内容颜色和图例(legend)颜色相匹配(和分组线图的颜色相匹配、match colors of groups)
Win11动态磁贴没了?Win11中恢复动态磁贴的方法
mysql 表读锁
JWT diagram
开发者如何为React Native选择合适的数据库
Visual studio 2022 view class diagram
Matlab -- CVX optimization kit installation
MySQL global lock
MySQL intent lock
Understand "average load"
行云管家V6.5.1/2/3系列版本发布:数据库OpenAPI能力持续强化
报表工具的二次革命
Sword finger offer | number of 1 in binary
Gap locks