zoukankan      html  css  js  c++  java
  • [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>
  • 相关阅读:
    android listview simpleAdaper
    android appwigt
    android shortcut &livefoulder
    android 命令行
    React Native for Android 学习笔记
    android dialog
    android Menu
    Android Gallery
    Android Listview
    Android
  • 原文地址:https://www.cnblogs.com/Answer1215/p/9363583.html
Copyright © 2011-2022 走看看