微信小程序通用组件

  1. 显示效果
    在这里插入图片描述

  2. 抽出
    在这里插入图片描述

  3. 定义
    在这里插入图片描述

<view class='main_recommend'>
  <image class='main_recommend_image' src="{{ imageUrl }}"></image>
  <view class='main_recommend_title'>{{ title }}</view>
  <view class='main_recommend_content'>{{ content }}</view>
</view>
.main_recommend {
  height: 180rpx;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  display: flex;
}

.main_recommend_image {
  width: 60rpx;
  height: 60rpx;
}

.main_recommend_title {
  font-size: 30rpx;
  color: #000000;
  margin-top: 5rpx;
}

.main_recommend_content {
  font-size: 20rpx;
  color: #cac9c9;
  margin-top: 5rpx;
}
{
  "component": true
}
Component({ 
  options: { 
    multipleSlots: true // 在组件定义时的选项中启用多slot支持 
  }, 
  /** 
   * 组件的属性列表 
   * 用于组件自定义设置 
  */ 
  properties: {
    // 图片 
    imageUrl: { // 属性名 
      type: String, // 类型(必填),目前接受的类型包括:String, Number, Boolean, Object, Array, null(表示任意类型) 
      value: '' // 属性初始值(可选),如果未指定则会根据类型选择一个 
    }, 
    // 标题
    title: { 
      type: String, 
      value: '' 
    }, 
    // 内容 
    content: { 
      type: String,
       value: '' 
      }, 
  }, 
  /** 
   * 私有数据,组件的初始数据 
   * 可用于模版渲染 
   */ 
  data: { 
    isShow: false
  }, 
  /**
   * 组件的方法列表 
   * 更新属性和数据的方法与更新页面数据的方法类似 
  */ 
  methods: { 
    /** 
    * 公有方法 
    */
    // 一些方法 
    someMethod() { 
      this.setData({ 
        isShow: !this.data.isShow
      }) 
    }, 
    /** 
     * 内部私有方法建议以下划线开头 
     * triggerEvent 用于触发事件 
    */ 
    _cancelEvent() { //触发取消回调 
      
    }, 
  } 
})
  1. 使用
<view class="recommend-view">
    <mainRe imageUrl="../../img/home/ic_top_1.png" title="优质任务" content="各种高质量的任务"></mainRe>
    <mainRe imageUrl="../../img/home/ic_top_2.png" title="高薪兼职" content="有着丰厚回报"></mainRe>
    <mainRe imageUrl="../../img/home/ic_top_3.png" title="企业任务" content="合作企业发布的任务"></mainRe>
  </view>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值