首页 > 其他分享 >vue3.2+ts 子组件的props接收的是个对象的话

vue3.2+ts 子组件的props接收的是个对象的话

时间:2023-03-10 13:56:39浏览次数:37  
标签:console log props ts vue3.2 JSON Props id

备忘录而已:

<script setup lang="ts">
// import {PropType} from "vue"
export interface DataInfo{
id:number;
name:string
}
type Props = {
isObject?:DataInfo
}
// const props = defineProps({
// isObject: Object as PropType<DataInfo>,
// })
// // const props = defineProps<Props>()
// // let {id,name} = props
// console.log('props:',props);
// console.log('打印Props:',JSON.parse(JSON.stringify(props)))
const props = withDefaults(defineProps<Props>(), {
isObject: ()=> {return {name: '姓名',id: 12}}
})
console.log('打印Props:',JSON.parse(JSON.stringify(props)))
</script>

 

标签:console,log,props,ts,vue3.2,JSON,Props,id
From: https://www.cnblogs.com/ch-zaizai/p/17203099.html

相关文章

  • 【814】Static hotspot analysis and emerging hotspot analysis based on the R libr
    Ref:EmergingHotSpotAnalysisRef:Ref:Statichotspotanalysislibrary(tidyverse)library(sf)library(openxlsx)library(ggplot2)library(tmap)tmap_mode("......
  • 多光源渲染方案 - Many Lights Sampling
    目录ImportanceSampling(IS)LightBVH[2018~2019]预构建BVH重建BVH基于BVHnode的ISReal-timeStochasticLightcuts[2020]莫顿序排序(MortonOrderSofting)构建Ligh......
  • jquery遍历元素children、find、parent、parents、parentsUntil、next、prev、sibling
    ​​​​全栈工程师开发手册(作者:栾鹏)​​jquery系列教程2-DOM操作全解​​jquery遍历元素jquery元素的函数包括children、find、parent、parents、parentsUntil、next......
  • 好客租房66-render-props模式-2使用模式
    使用步骤创建Mouse组件,在组件中提供复用状态逻辑代码(1:状态2操作状态的方法)2将要复用的状态作为props.render(state)方法的参数暴露到组件外部//导入reactimportRea......
  • 字节输入流_FileInputStream
    publicstaticvoidmain(String[]args){//字节流的读操作FileInputStreamf=null;try{//注意:读取数据的时候,如果文件......
  • D. Buying gifts
    D.BuyinggiftsLittleSashahastwofriends,whomhewantstopleasewithgiftsontheEighthofMarch.Todothis,hewenttothelargestshoppingcenterin......
  • Python__slots__魔法
    1、__slots__魔法在Python中,每个类都有实例属性。默认情况下Python⽤⼀个字典(__dict__属性)来保存⼀个对象的实例属性。这⾮常有⽤,因为它允许我们在运⾏时去设置任意的......
  • HDLBits(15)3.9
    3电路3.2时序逻辑3.2.1锁存器与触发器(LatchesandFlip-Flops)CreatecircuitfromtruthtableJK触发器的真值表如下图所示,仅使用D触发器和门电路来实现该JK触发......
  • 002lts相关
    一、(1)LTSSQL查询语法https://support.huaweicloud.com/sqlreference-lts/lts_sql_0004.html (2)"Druid德鲁"查询语法http://www.apache-druid.cn/Querying/druids......
  • 深入认识setState
    深入认识React类组建修改状态-setStatesetState,它对状态的改变,可能是异步的;如果改变状态的代码处于HTML元素事件中,则其是异步的,否则是同步如果遇到某个事件中,需要同步......