看完之后能感覺到就是想要把blog-post-row的內容放在table中的tr標簽中,是通過:is特性來進行使用的。但是感覺不知道具體怎么用,那就下面的這個示例再直觀的感受一下:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
<div id="app1">
<el-table :data="tableData">
<el-table-column is="blog_post_row"></el-table-column>
</el-table>
</div>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀區金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀區金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀區金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀區金沙江路 1516 弄'
}],
msg: 'Welcome to Your Vue.js App'
}
},
methods: {},
components: {
blog_post_row: {
template: `
<div>
<el-table-column prop="date" label="日期" width="180"></el-table-column>
<el-table-column prop="name" label="姓名" width="180"></el-table-column>
<el-table-column prop="address" label="地址" width="180"></el-table-column>
</div>
`
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
————————————————
也可以看一下其他朋友的示例哈:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
<div id="app1">
<button @click="toshow">點擊讓子組件顯示</button>
<component :is="which_to_show"></component>
</div>
</div>
</template>
<script>
import Vue from 'vue'
/* eslint-disable no-new */
export default {
name: 'HelloWorld',
data () {
return {
which_to_show: 'first',
msg: 'Welcome to Your Vue.js App'
}
},
methods: {
toshow: function () {
var arr = ['first', 'second', 'third', '']
var index = arr.indexOf(this.which_to_show)
if (index < 3) {
this.which_to_show = arr[index + 1]
} else {
this.which_to_show = arr[0]
}
}
},
components: {
first: {
template: `<div>這里是子組件</div>`
},
second: {
template: `<div>這里是子組件2</div>`
},
third: {
template: `<div>這里是子組件3</div>`
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
————————————————