1.創建自定義文件
<template name="組件名稱">
<view>
......
</view>
</template>
<script>
export default {
name: "組件名稱",
//屬性
props: {
屬性名稱: {
type: String,//屬性類型
value: "值"
},
......
},
//組件生命周期
created:function(e){
},
methods: {
函數名稱:function(obj){
},
}
}
</script>
<style>
組件樣式
</style>
2.組件引用
1、引用組件
import 組件名稱 from "../../components/組件名.vue";
2、注冊組件
export default{
components:{
組件名稱
},
}
3、在試圖模板中使用組件
<組件名稱 組件屬性="對應的值"></組件名稱>
