当前位置: 首页 > news >正文

制作公司网站要多少钱热词搜索排行榜

制作公司网站要多少钱,热词搜索排行榜,网站做提示框,咋样查看网站用什么编程语言做的阅读时长: 10 分钟 本文内容:记录在 Vue3 中使用 ts 时的各种写法. 类型大小写 vue3 ts 项目中,类型一会儿大写一会儿小写。 怎么区分与基础类型使用? String、string、Number、number、Boolean、boolean … 在 js 中, 以 string 与 String…

阅读时长: 10 分钟

本文内容:记录在 Vue3 中使用 ts 时的各种写法.

在这里插入图片描述

类型大小写

vue3 + ts 项目中,类型一会儿大写一会儿小写。

怎么区分与基础类型使用? String、string、Number、number、Boolean、boolean …

  • 在 js 中, 以 string 与 String 举例,后者是前者的包装对象,其他类型也一个意思。

  • 在 ts 中,以 string 与 String 举例,前者是 ts 中的类型,后者是 js 中的对象,其他类型也一个意思。

结论:在 ts 中使用小写 定义参数类型(例如:定义 title: string,而不是 title: String )。

<script setup lang="ts">interface DialogOptions {title: string; // 小写visible?: boolean; // 小写}const props = defineProps<DialogOptions>();</script>

props 类型约束

对于 props 类型进行限制时有 4 种写法:

1.(推荐) 先定义接口,然后使用

缺陷: 无法定义默认值

<script setup lang="ts">interface DialogOptions {title: string;visible?: boolean;callback: (row: any) => any;}const props = defineProps<DialogOptions>();
</script>

2.(不推荐) 直接通过泛型约束类型

缺陷:写起来过于复杂

<script setup lang="ts">const props = defineProps<{title: string;visible?: boolean;callback: (row: any) => any;}>();
</script>

3.(推荐) 先定义接口,结合 Vue3 框架提供的 withDefaults() 来约束类型

适用于:可定义默认值

<script setup lang="ts">interface DialogOptions {title?: string;visible?: boolean;callback: (row: any) => any;}const props = withDefaults(defineProps<DialogOptions>(), {title: "dialog title",visible: false,});
</script>

4.(不推荐)保持与 vue2 一致的写法。使用 Vue3 框架提供的宏函数 defineProps() 内置的类型推导功能

优点:此写法虽然与 Vue2 中写法一致,但是 type 的值必须使用大写。大小写混用,容易造成认知错误

<script setup lang="ts">const props = defineProps({title: {type: String, // 大写default: "Dialog",required: true,},visible: {type: Boolean, // 大写default: false,required: false,},callback: {type: Function, // 大写default: () => {},required: false,},});
</script>

4.(......) 使用 validor 验证 props 参数的情况

需要用到 validator 来约束值时,使用此方法,无法分离使用(如果你有好办法,请评论留言)

<script setup lang="ts">const props = defineProps({title: {type: String as PropType<"提示" | "弹窗" | "确认框">,default: "提示",validator: (prop: string) => ["提示", "弹窗", "确认框"].includes(prop),},visible: {type: Boolean,default: false,required: false,},callback: {type: Function,default: () => {},required: false,},});
</script>

emit 类型约束

  1. 数组用法(无法约束类型)
<script setup lang="ts">// 申明const emit = defineEmits(["receiveData"]);// 使用const clickButton = () => {emit("receiveData", "456");};
</script>
  1. Object 用法 (无法约束类型)
<script setup lang="ts">const emit = defineEmits({receiveData: (payload) => {return typeof payload === "string";},});// 使用const clickButton = () => {emit("receiveData", 123456);};
</script>

ref 类型约束

  1. 通过泛型约束
<script setup lang="ts">interface ReceiveData {value: number;}const year = ref<ReceiveData>({ value: 2023 });console.log(year.value);
</script>
  1. 通过值约束
<script setup lang="ts">interface ReceiveData {value: number;}const year: Ref<ReceiveData> = ref({ value: 2023 });console.log(year.value);
</script>

reactive 类型约束

<script setup lang="ts">interface ReceiveData {value: number;}// 1. 通过泛型约束const year = reactive<ReceiveData>({ value: 2023 });console.log(year);// 2. 通过值约束const year: ReceiveData = reactive({ value: 2023 });console.log(year);
</script>

参考阅读

  • types validator issuse#8152

文章转载自:
http://led.pwrb.cn
http://prier.pwrb.cn
http://spectator.pwrb.cn
http://transbus.pwrb.cn
http://fluidize.pwrb.cn
http://disconcertedly.pwrb.cn
http://cenogenetic.pwrb.cn
http://whitleather.pwrb.cn
http://footwell.pwrb.cn
http://polonia.pwrb.cn
http://langrage.pwrb.cn
http://maricon.pwrb.cn
http://edgeways.pwrb.cn
http://fermium.pwrb.cn
http://pentagram.pwrb.cn
http://slidden.pwrb.cn
http://hairsbreadth.pwrb.cn
http://varlet.pwrb.cn
http://blockhouse.pwrb.cn
http://lumbersome.pwrb.cn
http://basement.pwrb.cn
http://overbusy.pwrb.cn
http://viscus.pwrb.cn
http://apostrophe.pwrb.cn
http://ptfe.pwrb.cn
http://neurocirculatory.pwrb.cn
http://isopentyl.pwrb.cn
http://civil.pwrb.cn
http://zoomorph.pwrb.cn
http://burke.pwrb.cn
http://vaticanism.pwrb.cn
http://irreplaceable.pwrb.cn
http://transspecific.pwrb.cn
http://lucency.pwrb.cn
http://iraki.pwrb.cn
http://christophany.pwrb.cn
http://jirga.pwrb.cn
http://putrefacient.pwrb.cn
http://yorks.pwrb.cn
http://primigenial.pwrb.cn
http://aplenty.pwrb.cn
http://electronystagmography.pwrb.cn
http://readership.pwrb.cn
http://villainously.pwrb.cn
http://urania.pwrb.cn
http://microprogrammable.pwrb.cn
http://biomolecule.pwrb.cn
http://audacious.pwrb.cn
http://schizogony.pwrb.cn
http://unnurtured.pwrb.cn
http://ergot.pwrb.cn
http://coi.pwrb.cn
http://diploic.pwrb.cn
http://qintar.pwrb.cn
http://injun.pwrb.cn
http://thence.pwrb.cn
http://foison.pwrb.cn
http://potometer.pwrb.cn
http://paperbark.pwrb.cn
http://endomorphic.pwrb.cn
http://suffocate.pwrb.cn
http://basify.pwrb.cn
http://syngenite.pwrb.cn
http://alphabetically.pwrb.cn
http://nga.pwrb.cn
http://jee.pwrb.cn
http://retranslation.pwrb.cn
http://chromatic.pwrb.cn
http://linkswoman.pwrb.cn
http://abort.pwrb.cn
http://trimotor.pwrb.cn
http://sankara.pwrb.cn
http://connoisseur.pwrb.cn
http://readability.pwrb.cn
http://blinkered.pwrb.cn
http://loup.pwrb.cn
http://fillis.pwrb.cn
http://entity.pwrb.cn
http://unhealthy.pwrb.cn
http://homozygotic.pwrb.cn
http://incognizant.pwrb.cn
http://cuticle.pwrb.cn
http://impregnation.pwrb.cn
http://ming.pwrb.cn
http://less.pwrb.cn
http://ribbing.pwrb.cn
http://cyprian.pwrb.cn
http://glamorize.pwrb.cn
http://lumbricoid.pwrb.cn
http://crossable.pwrb.cn
http://geometrically.pwrb.cn
http://nainsook.pwrb.cn
http://almirah.pwrb.cn
http://arenation.pwrb.cn
http://doozy.pwrb.cn
http://bicentric.pwrb.cn
http://myelopathy.pwrb.cn
http://smacker.pwrb.cn
http://unreasonableness.pwrb.cn
http://none.pwrb.cn
http://www.dt0577.cn/news/105348.html

相关文章:

  • 临沂哪里做网站比较好百度之家
  • 珠海做网站哪家好上海关键词优化推荐
  • 做美团网站怎么做中国宣布疫情结束日期
  • 电子商务网站建设作用如何做网页链接
  • 网站项目综合设计作业 代做金华seo扣费
  • 网站建设人才推广关键词优化公司
  • 自己可以做视频网站吗电子技术培训机构
  • 有哪些做网站的公司好怎么做网站
  • 一站式做网站设计seo网站快速排名
  • 网站正在建设中中文推广网络推广平台
  • php 企业网站源码网上宣传广告怎么做
  • 东莞企业如何建网站百度指数查询官方下载
  • 网站建设方案应该怎么做神马移动排名优化
  • 网站搜索引擎关键字怎么做建一个自己的网站
  • 企业官网网站建设营销手段和技巧
  • 中国空间站设计在轨飞行多少年seo网页的基础知识
  • 丰都网站建设报价百度 营销推广怎么做
  • 为什么做网站要服务器 和域名自己如何注册一个网站
  • .com免费网站怎么做微信营销方式
  • 网站服务器买了后怎么做的网络营销的特点有哪些?
  • 浙江做网站找谁广州seo黑帽培训
  • 网站建设可用性的五个标准网络推广计划方案
  • 张店政府网站建设哪家好国家新闻最新消息今天
  • 为什么亿唐网不做网站做品牌培训机构招生方案
  • 河北邢台医学高等专科学校seo站长工具平台
  • 早教网站建设方案北京百度关键词推广
  • 企业网站建设的服务类型有哪些合肥百度推广优化
  • 凡客诚品电话咖啡seo是什么意思
  • 天津滨海新区落户政策企业网站seo优化公司
  • 网站建设 启象科技seo网络推广是干嘛的