[Vue @Component] Write Vue Functional Components Inline
2024-10-19 16:23:45
Vue's functional components are small and flexible enough to be declared inside of .vue file next to the main component. This allows you to mix jsx and Vue's templates so you have complete control over how to render your content.
Robot.vue:
<script>
export default {
functional: true,
render: (h, {props, data}) => {
return props.names.map(
name => `https://robohash.org/${name}?set=set${props.num}`
).map(
url => <div><img src={url} alt="" /></div>
);
}
}
</script>
Using:
<template>
<section slot="content" class="flex flex-row flex-no-wrap">
<Robot :names="names" :num="2"></Robot>
</section>
</template> <script>
@Component({
components: {
Layout,
Settings,
Robot
}
})
export default class HelloWorld extends Vue {
@Prop({
default: ["mindy", "john", "kim", "joel", "ben"]
}) names
}
</script>
最新文章
- 前台获取Dropdownlist选中的text
- docker 数据卷 权限
- java入门必备单词
- C# vs C++ Performance
- IBatis.Net系列-多参数的SQL语句的配置
- Oracle 安装 检查操作系统版本 必须是 5.0 5.1 的解决办法
- :app:transformResourcesWithMergeJavaResForDebug FAILED
- 交叉编译和使用HTOP
- Keil 二进制数输入宏
- JS页面打开方式丶对话框及页面跳转方式
- openstack中使用linux_bridge实现vxlan网络
- bzoj 2724 蒲公英 分块
- asp.net core 将配置文件配置迁移到数据库(一)
- 高性能消息队列NSQ
- Java实现简单计算器、抽票程序
- rrnDB数据库简介-16S基因多拷贝数的证据
- GoLand(二)语言结构和基础语法
- 怎么查看在centos中创建的用户组
- CSS鼠标手势
- 使用RStudio学习一个简单神经网络