当前位置:网站首页>01.一个更简单的方法来传递大量的props
01.一个更简单的方法来传递大量的props
2022-07-25 15:59:00 【@大迁世界】
今天,我们来学习一下 Vue 技巧小册,本节是第一节课,也就是标题所示: 用更简单的方式来传递大量的 props,事例是用 vue3来演示的,当然在 vue2 中也适用。
我们直接进入正题,假设我们有一个显示用户信息的组件,如下所示:
<template>
<div>
<p>姓名:{
{ name }}</p>
<p>职业:{
{ job }}</p>
<p>年龄:{
{ age }}</p>
</div>
</template>
<script setup>
import { ref } from 'vue'
defineProps({
name: String,
job: String,
age: Number,
})
const count = ref(0)
</script>
该组件接收三个参数,分别是 用户姓名、工作、以及年龄。在 template 中把对应的这三个字段值显示出来。
然后,在父组件中,引入 User 组件,声明一个 userInfo 对象,然后给 User 组件传入这三个参数,如下所示:
<template>
<User :name="userInfo.name" :job="userInfo.job" :age="userInfo.age" />
</template>
<script setup>
import { reactive } from 'vu边栏推荐
- 没错,请求DNS服务器还可以使用UDP协议
- Gap Locks(间隙锁)
- Sword finger offer | number of 1 in binary
- Matlab -- CVX optimization kit installation
- Wavelet transform --dwt2 and wavedec2
- Baseband simulation system experiment of 4pam in Gaussian channel and Rayleigh channel
- Activity review | July 6 Anyuan AI X machine heart series lecture No. 2 | MIT professor Max tegmark shares "symbiotic evolution of human and AI"
- Save the image with gaussdb (for redis), and the recommended business can easily reduce the cost by 60%
- 食品安全丨无处不在的冷冻食品,你真的了解吗?
- C# 音乐
猜你喜欢

通用测试用例写作规范

Product upgrade observation station in June

Wavelet transform --dwt2 and wavedec2

Which led display manufacturer is better

Circulaindicator component, which makes the indicator style more diversified
![[server data recovery] data recovery cases of raid information loss caused by unexpected power failure of HP EVA server storage](/img/90/51d86111b918eb60761818110cdec4.jpg)
[server data recovery] data recovery cases of raid information loss caused by unexpected power failure of HP EVA server storage

Waterfall flow layout

Crazy God redis notes 12

基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现

面试8家公司,1周拿了5个offer,分享一下自己的心得
随机推荐
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
MySQL implicit lock
MySQL-自增锁
终极套娃 2.0 | 云原生交付的封装
MySQL table write lock
leetcode:528. 按权重随机选择【普通随机失效 + 要用前缀和二分】
Endnote cannot edit range resolution
MySQL intent lock
mysql 查看是否锁表
Mysql读写锁
Reasons for data format conversion when matlab reads the displayed image
Record locks
Wavelet transform --dwt2 and wavedec2
mysql 隔离级别事务
Exploration of 6-wire SPI transmission mode
How matlab saves all the data after running
Analysis and solution of data and clock mismatch delay in SPI transmission
Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
C# 音乐
通用测试用例写作规范