
使用之前要创建
在 components 文件下创建一个自己的 组件文件(.vue)
初始结构为
<!--html区域-->
<template>
</template>
<!--JS区域-->
<script>
export default {
name: "hw"
}
</script>
<!--css区域-->
<style scoped>
</style>加入自己的代码设置就完成了一个简单的 子组件文件 创建
<!--html区域-->
<template>
<p class="hw">
{{ name }}
</p>
</template>
<!--JS区域-->
<script>
export default {
name: "hw",
data(){
return {
name:"毛没齐"
}
}
}
</script>
<!--css区域-->
<style scoped>
.hw{
color: blue;
}
</style>子组件创建好后 就要注册它,只有注册了才能使用
注册分为
1.局部注册组件 :在App.vue文件中注册 也在App.vue文件使用
2.全局注册组件:在main.js文件中注册
全局注册组件后,在 App.vue文件使用
相关推荐:
使用 Vue.js 创建的 Calendar_html/css_WEB-ITnose
什么是Vue.js组件?Vue.js组件用法汇总
