Vue系列十六:vue组件
一、组件由三个部分组成
1、模板页面
<template>
</template>
2、 JS 模块对象
<script>
export default{
data(){
return{}
},
methods:{},
computed:{},
components:{}
}
</script>
3、样式
<style>
</style>
二、基本使用
1、引入组件
2、映射成标签。标签名与标签属性名书写问题:
(1)、写法一: 一模一样。 <HelloWorld></HelloWorld>
(2)、写法二: 大写变小写,并用-连接。<hello-world></hello-world>
3、使用组件标签
<template>
<HelloWorld></HelloWorld>
<hello-world></hello-world>
</template>
<script>
import HelloWorld from'./components/HelloWorld'
export default{
components:{
HelloWorld
}
}
</script>
还没有评论,来说两句吧...