uniapp中自定义组件的封装及使用

在项目根目录下,创建 components 文件夹,新建文件myinput.vue。

<template name="myinput">
<view>
    <input class="myinput" type="text" placeholder="请输入信息" value="" />
</view>
</template>

<script>
export default {
  name: 'myinput',
  props: {
            
  },
  data() {
    return {
                
    }
  },
  methods: {
            
  }
}
</script>

<style>
.myinput{padding: 20upx;background: #f4f5f6;}
</style>

在index.vue中引用:

<myinput></myinput>

<script>
import myinput from '../../components/myinput.vue'
export default {
    components:{
    myinput
    },
}
</script>

 

posted on 2020-05-22 17:06  JoeYoung  阅读(14829)  评论(0编辑  收藏  举报