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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM