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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM