uni-app 自定义组件的创建和使用

开发工具:HbuilderX

组件的创建:

根目录下--》新建--》新建目录(compenents)--》目录下 新建组件(test)--》使用默认模版 

【test.vue即为组件文件】

组件的使用:

//index.vue

<script>
  //(1)引入 import test from '../../components/test.vue'
  export
default {   //(2)注册 components:{ test,//"test":test 缩写为test } } </script>

<template>
  <view class="content">
    <test></test> //(3)使用组件:

  </view>
</template>

 

posted @ 2020-05-14 10:28  蓝精灵61  阅读(3256)  评论(0)    收藏  举报