uni-app自定义组件的注册和调用

uniapp自定义组件的注册
easycom规范components/组件名/组件名.vue
在这里插入图片描述
pageHead.vue 组件注册

<template name="pageHead">
	<view>
		{{title}}---{{detail}}
	</view>
</template>

<script>
	export default {
		name: "pageHead",
		props: {
			title: {
				type: String,
				default: "hello"
			},
			detail: {
				type: String,
				default: "你好"
			}
		},
		created() {
			
		},
		methods:{
			
		}
	}
</script>

index.vue 组件调用

<template>
	<view>
		 <pageHead :title="title" :detail="detail"></pageHead>
	</view>
</template>

<script>
	export default {
		onLoad() {
		 
		},
		data() {
			return {
				title: "hello",
				detail:"你好"
			}
		}
	}
</script>

你可能感兴趣的:(uni-app,vue.js,javascript,前端)