1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| <template> <div class="dvapp">
<h2>app组件</h2> <div class="dvslot"> <Category title="美食"> <img slot="center" src="https://s2.ax1x.com/2021/01/16/srJ1q0.jpg" style="width:100%;" alt="美食" /> <div class="footer" slot="footer"> <a href="http://odinsam.com">热门美食</a><a href="http://odinsam.com">更多美食</a> </div> </Category> <Category title="游戏"> <ul slot="center"> <li v-for="(g,index) in games" :key="index">{{g}}</li> </ul> <a class="footer" slot="footer" href="http://odinsam.com">热门游戏</a> </Category> <Category title="影视"> <video slot="center" controls src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video> <template v-slot:footer> <div class="footer"> <a href="http://odinsam.com">热门</a> <a href="http://odinsam.com">经典</a> <a href="http://odinsam.com">推荐</a> </div> <h4>欢迎观看</h4> </template> </Category> <Student title="作用于插槽"> <template slot-scope="{stus,msg}"> <ul slot="center"> <h4 v-for="stu in stus" :key="stu.id">{{stu.name}}</h4> </ul> <h4>{{msg}}</h4> </template> </Student> </div> </div> </template>
<script> import Category from './components/Category.vue'; import Student from './components/Student.vue'; export default { name: 'App', data() { return { 'foods': ['火锅', '小龙虾', '牛排', '烧烤'], 'games': ['魔兽', '炉石', '暗黑', '星际'], 'films':['西游','三国','红楼梦','水浒'] } }, components: { Category,Student }, methods: { }, } </script>
<style> #app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } .dvapp { background-color: aquamarine; } .dvslot { display: flex; justify-content: space-evenly; } video{ width:100%; } .footer { text-align: center; } </style>
|