[Vue @Component] Write Vue Functional Components Inline
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>
[Vue @Component] Write Vue Functional Components Inline的更多相关文章
- [Vue @Component] Extend Vue Components in TypeScript
This lesson shows how you can extend and reuse logic in Vue components using TypeScript inheritance. ...
- [Vue @Component] Pass Props Between Components with Vue Slot Scope & renderless component
Components with slots can expose their data by passing it into the slot and exposing the data using ...
- [Vue @Component] Load Vue Async Components
Vue provides a straight-forward syntax for loading components at runtime to help shave off initial b ...
- [Vue @Component] Dynamic Vue.js Components with the component element
You can dynamically switch between components in a template by using the reserved <component> ...
- [Vue @Component] Simplify Vue Components with vue-class-component
While traditional Vue components require a data function which returns an object and a method object ...
- [Vue @Component] Place Content in Components with Vue Slots
Vue's slots enable you to define where content of a component should land when you define the conten ...
- [Vue @Component] Pass Vue Render Functions as Props for Powerful Patterns
Render functions open up a world of customization and control by using pure JavaScript rather than V ...
- 前端框架vue.js系列(9):Vue.extend、Vue.component与new Vue
前端框架vue.js系列(9):Vue.extend.Vue.component与new Vue 本文链接:https://blog.csdn.net/zeping891103/article/det ...
- Vue Vue.use() / Vue.component / router-view
Vue.use Vue.use 的作用是安装插件 Vue.use 接收一个参数 如果这个参数是函数的话,Vue.use 直接调用这个函数注册组件 如果这个参数是对象的话,Vue.use 将调用 ins ...
随机推荐
- 重新学习Java——对象和类(二)
上一节回归了如何以面向对象的思想去使用一些Java中的公共类,也设计了一些自己的类并介绍了设计类的基本方法和技巧,这一节我们将继续回顾这些内容,并争取从中获得新的体验和感受. 1. 静态域与静态方法 ...
- 在struct 中使用string,赋值会报错
struct中最好使用char来代替string,因为string的大小不是固定的
- WordPress个性页面制作教程
写在前面的话: 有很多WordPress小伙伴想制作不同风格的页面来满足自己的个性需求 但是大多数模板提供的页面模板非常有限,该如何手动制作属于自己风格的模板页呢? 其实,正如以上所说的,每个人都想拥 ...
- Android 比SwipeRefreshLayout更漂亮和强大的下拉刷新控件:Android-MaterialRefreshLayout
这是一个下拉刷新的控件,它比SwipeRefreshLayout更加漂亮和强大.它易于使用并且支持API LEVEL >= 8.希望你能够喜欢. Now let me talk about Ma ...
- socket相关函数
socket() 我们使用系统调用socket()来获得文件描述符:#include<sys/types.h>#include<sys/socket.h>int socket( ...
- View Programming Guide for iOS
https://developer.apple.com/library/archive/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/Wi ...
- 梦想CAD控件安卓交互绘图
在cad使用过程中,动态绘制的使用会使我们绘图速度大大加快.在此演示中,我们绘制了直线.多段线.点.样条线.圆.圆弧.椭圆.椭圆弧等实体. 用户可以在CAD控件视区任意位置绘制直线. 主要用到函数说明 ...
- scala学习(3)-----wordcount【sparksession】
参考: spark中文官方网址:http://spark.apachecn.org/#/ https://www.iteblog.com/archives/1674.html 一.知识点: 1.Dat ...
- 简述systemd的新特性及unit常见类型分析、使用systemd管理编译安装的nginx
1. systemd新特性 并行处理(同时启动)所有服务. 基于依赖关系定义的服务控制逻辑 系统状态快照 按需激活进程,只有第一次被访问时才会真正启动: 2. systemd的常见unit类型 Ser ...
- selenium的调用
selenium的调用 制作人:全心全意 selenium调用谷歌浏览器 chrome = webdriver.Chrome() //创建谷歌浏览器对象 url="http://www.ba ...