App.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div class="container">
  3. <category title="游戏">
  4. <!-- 必须用template包裹,并且配置scope,scope的名字可以随意定 -->
  5. <template scope="atguigu">
  6. <ul>
  7. <li v-for="(g,index) in atguigu.games" :key="index">{{ g }}</li>
  8. </ul>
  9. </template>
  10. </category>
  11. <category title="游戏">
  12. <template scope="{games}">
  13. <ol>
  14. <li v-for="(g,index) in games" :key="index">{{ g }}</li>
  15. </ol>
  16. </template>
  17. </category>
  18. <category title="游戏">
  19. <template slot-scope="{games}">
  20. <h4 v-for="(g,index) in games" :key="index">{{ g }}</h4>
  21. </template>
  22. </category>
  23. </div>
  24. </template>
  25. <script>
  26. import Category from './components/Category.vue';
  27. export default {
  28. name: "App",
  29. components:{Category},
  30. };
  31. </script>
  32. <style>
  33. .container,.foot{
  34. display: flex;
  35. justify-content: space-around;
  36. }
  37. video{
  38. width: 100%;
  39. }
  40. h4{
  41. text-align: center;
  42. }
  43. </style>