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>

猜你喜欢

转载自www.cnblogs.com/joe235/p/12580039.html
今日推荐