vue 笔记:组件的使用

pages/index/index.vue

<template>
	<view class="content">
		<title></title>
	</view>
</template>

<script>
	import title from './components/title.vue'
	export default {
		data() {
			return {
			}
		},
		onLoad() {

		},
		methods: {

		},
		components:{
			title
		}
	}
</script>

<style>

</style>

/pages/index/components/title.vue

<template>
	<view class="">
		我是title
	</view>
</template>

<script>
	
</script>

<style scoped>
	
</style>

  其他笔记:在style 标签内写了scoped 标识该样式属于私有的样式,被引用的时候不会被其他样式覆盖。但是app.vue内的公共样式除外。

原文地址:https://www.cnblogs.com/Dmail/p/13300831.html