【发布时间】:2017-08-22 21:08:07
【问题描述】:
这是我目前编写 Vue 组件的方式。例如
<template>
<NavBar></NavBar>
<div class="Footer">
<div class="left">
<p>I'm a cool footer on the Left!</p>
</div>
<div class="middle">
</div>
<div class="right">
<p>I'm a cool footer on the Right!</p>
</div>
</div>
</template>
<script>
import NavBar from './NavBar.vue';
export default {
name: 'Footer',
components: {
NavBar
}
data () {
return {
}
},
methods: {
}
}
我的问题是我应该这样写我的组件吗?如果有,有什么区别?
Vue.component('my-component', {
template: '<div>A custom component!</div>'
})
new Vue({
el: '#example'
})
【问题讨论】: