标签:col 动态 tps ice one color 出现 元素 示例
porps:{
books:{
type: Array,
required: true,
default: ‘四大名著‘
}
}
<book-template :books=‘books‘></book-template>
<h4>{{title}}</h4> <div>此标签没有包含在同一根元素下,而是和上面的标签并列</div>
<div id="father"> <h4>{{title}}</h4> <div>此标签包含在同一根元素下,都包含在id为father的div下</div> </div>
整体的测试代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://cdn.jsdelivr.net/npm/vue"></script> <title>Vue中给自定义属性添加属性</title> </head> <body> <div id="app"> <book-template :books=‘books‘></book-template> </div> <script> Vue.component("book-template", { props: [‘books‘], template: ` <table> <thead> <tr> <th>序号</th> <th>书名</th> <th>作者</th> </tr> </thead> <tbody> <tr v-for="book,index in books"> <td>{{index+1}}</td> <td>{{book.title}}</td> <td>{{book.author}}</td> </tr> </tbody> </table> ` }) new Vue({ el: ‘#app‘, data: { books: [{ title: ‘水浒传‘, author: ‘施耐庵‘, }, { title: ‘三国演义‘, author: ‘罗贯中‘, } ] } }) </script> </body> </html>
标签:col 动态 tps ice one color 出现 元素 示例
原文地址:https://www.cnblogs.com/xshan/p/12336975.html