uni-app全局组件引用

1 components文件下的vue文件

<template name="page-head">
	<view class="uni-page-head">
		<view class="uni-page-head-title">{{title}}</view>
	</view>
</template>
<script>
	export default {
		name: "page-head",
		props: {
			title: {
				type: String,
				default: ""
			}
		}
	}
</script>

2 main.js

import pageHead from './components/page-head.vue'

Vue.component('page-head',pageHead)

3 需要引用的文件下

<page-head :title="title"></page-head>

猜你喜欢

转载自blog.csdn.net/qq_37902065/article/details/84874242