1 组件都包括什么?

2模板 script style

<template>

  <div class="item"><div>

</template>

<script>

export default {//导出组件

}

</script>

<style scoped>//scoped表示局部的,范围的

item{

  cursor:pointer;

}

item:hover{

  background:#f4f4f4;

}

</style>

2 如何使用组件:

(1)首先需要引入:import * from "./components/item";(./代表当前目录,但是这里引入的时候一定要写上./要不会从node_modules文件去找)

  (2)  注册组件 

(3)

<template>

  <item/>

</template>

<script>

import Item from "./components/item";

export default{

    components:{//注册组件

        Item,

    }

}

</script>

<style scoped>

</style>

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐