数据必须是对象
<script> import Content from "./components/Content.vue"; export default { data() { return { }; }, components:{ Content } }</script><template> <div> <Content></Content> <Content></Content> <Content></Content> </div></template>
<template> <div> <!--组件是能够复用 --> <Hello_kugou></Hello_kugou> <h2> content hello </h2> <h3>{{msg}}</h3> <button @click="msg='酷狗'"> chagebut</button> <Hello_kugou></Hello_kugou> </div></template><script>import Hello_kugou from "./Hello_kugou.vue";export default { data(){ return{ msg: 'hellokugoumsg' }; }, components:{ Hello_kugou }, name: "Content"}</script><style scoped></style>
<template> <div> <h2>hello kugou</h2> </div></template><script>export default { name: "Hello_kugou"}</script><style scoped></style>