这是我目前正在编写我的Vue组件的方式。例如。我正在写我的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'
})
我会尽可能让你的开发变得容易,并且可以很容易地理解应用程序结构。 – mrogers