zoukankan      html  css  js  c++  java
  • 606 uniapp自定义组件


    index.vue

    <template>
      <view>
        <btn color="red" background-color="skyblue" @change="change">点击我啊</btn>
      </view>
    </template>
    
    <script>
      // 是@/,不要漏了斜杠/
      import btn from '@/components/btn/btn'
    
      export default {
        data() {
          return {
    
          };
        },
        components: {
          btn
        },
        methods: {
          change(params) {
            console.log('index---', params) // index--- red
          }
        }
    
      }
    </script>
    
    <style>
    
    </style>
    

    btn.vue

    <template>
      <view>
        <button type="default" class="btn" :style="{color: color, backgroundColor: backgroundColor}" @click="btnChange">
          <slot>按钮啊</slot>
        </button>
      </view>
    </template>
    
    <script>
      export default {
        data() {
          return {
    
          };
        },
        props: {
          color: {
            type: String,
            default: '#000'
          },
          backgroundColor: {
            type: String,
            default: '#ccc'
          }
        },
        methods: {
          btnChange() {
            console.log(111)
            this.$emit('change', this.color)
          }
        }
      }
    </script>
    
    <style>
    
    </style>
    
  • 相关阅读:
    网页抓取
    基本数据结构
    小节
    顺序统计量
    线性时间排序
    快速排序
    堆排序 Heapsort
    大数运算
    趣味题,文本中洞的数量
    nginx config配置
  • 原文地址:https://www.cnblogs.com/jianjie/p/14400982.html
Copyright © 2011-2022 走看看