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的更多相关文章

  1. [Vue @Component] Extend Vue Components in TypeScript

    This lesson shows how you can extend and reuse logic in Vue components using TypeScript inheritance. ...

  2. [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  ...

  3. [Vue @Component] Load Vue Async Components

    Vue provides a straight-forward syntax for loading components at runtime to help shave off initial b ...

  4. [Vue @Component] Dynamic Vue.js Components with the component element

    You can dynamically switch between components in a template by using the reserved <component>  ...

  5. [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 ...

  6. [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 ...

  7. [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 ...

  8. 前端框架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 ...

  9. Vue Vue.use() / Vue.component / router-view

    Vue.use Vue.use 的作用是安装插件 Vue.use 接收一个参数 如果这个参数是函数的话,Vue.use 直接调用这个函数注册组件 如果这个参数是对象的话,Vue.use 将调用 ins ...

随机推荐

  1. 致创业者:APP已死 服务永生

    前几日,有位创业者和我讲他在带领团队做一个将爱踢球的人集中在一起的App,我告诉他你的创业方向错了.原因在于你的目的是要为爱踢球的人提供服务,而你现在却在竭尽全力的做App,你应该做的是设计你为爱踢球 ...

  2. [ CQOI 2014 ] 数三角形

    \(\\\) Description 求 \(N\times M\) 的网格图上有多少个格点构成的三角形. 当三点共线的时候我们不认为这是一个三角形. \(n,m\le 10^4\) \(\\\) S ...

  3. Ubuntu下查看服务器cpu是否支持VT

    http://blog.51cto.com/zhangmingqian/1249522 Ubuntu下查看服务器cpu是否支持VT 原创wazjajl 2013-07-15 16:25评论(0)119 ...

  4. 动态排序JavaBean

    Java中如果对对象排序可以考虑实现Comparable接口,但是需要排序的属性一旦指定就不能再修改.BeanUtils组件提供了对JavaBean动态排序的支持,即可以在运行时指定排序的属性.实例运 ...

  5. python行与缩进

    #python行与缩进 1.了解逻辑行与物理行 2.行中分号使用规则 3.行链接 4.什么是缩进 5.如何缩进 6.注释 1.python中逻辑行主要是指一段代码,在意义上它的行数,而物理行,指的是我 ...

  6. Change the color of a link in an NSMutableAttributedString

    Swift Updated for Swift 3 Use with a textView.linkTextAttributes = [NSForegroundColorAttributeName: ...

  7. Java必知必会的20种常用类库和API

    转载:https://blog.csdn.net/u011001084/article/details/79216958 个人感觉工具类对日常开发是很重要的,所以推荐一下这篇文章,虽然有的类库过时了 ...

  8. vue基础---条件渲染

    (1)v-if条件渲染 v-if 指令用于条件性地渲染一块内容.这块内容只会在指令的表达式返回 truthy 值的时候被渲染. 可以用 v-else 添加一个“else 块”: ①表达式 <di ...

  9. UVA - 1608 Non-boring sequences(分治法)

    题目: 如果一个序列的任意连续的子序列中至少有一个只出现一次的元素,则称这个序列是不无聊的.输入一个n(n≤200000)个元素的序列A(各个元素均为109以内的非负整数),判断它是不是不无聊的. 思 ...

  10. <MyBatis>入门二 全局配置文件

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC ...