结合ColorUI组件开发微信小程序

1.自定义组件生命周期函数:

javascript 复制代码
Component({
  data: {


  },


  attached() {
    console.log("自定义组件生命周期函数 attached--先执行");
    this.getPos();
  },


  ready() {
    console.log("ready生命周期函数---在attached之后执行")
  },


  methods: {
    getPos() {
      var that = this;
      console.log("ssss")
      wx.getLocation({
        type: "wgs84",
        isHighAccuracy: true,
        success: function (res) {
          console.log('纬度' + res.latitude);
          console.log('经度' + res.longitude);
          that.setData({
            latitude: res.latitude,
            longitude: res.longitude,
          })
        }
      })
    }
  }
})

2.使用ColorUI定义的列表样式:

html 复制代码
<view class="cu-list menu">
      <view class="cu-item">
        <view class="content">
          <text class="cuIcon-locationfill text-grey"></text>
          <text class="text-black">地址</text>
          <text class="text-grey text-xs detailPos">详细地址</text>
        </view>
      </view>
 </view>


3.使用ColorUI定义的图标样式:
<text class="cuIcon-locationfill text-grey"></text>

4.可上下滚动的列表:
(1).wxml:

html 复制代码
  <view class="posList">

    <scroll-view scroll-y="true" style="height: 100%" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
      <view class="cu-list menu">
        <view class="cu-item" wx:for="{{itemsPos}}" wx:for-item="item" wx:key="index">
          <view class="content">
            <text class="cuIcon-locationfill text-grey"></text>
            <text class="text-black">{{item.pos}}</text>
            <text class="text-grey text-xs detailPos">{{item.detailPos}}</text>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>

(2).js文件:

javascript 复制代码
scrollToTop() {
    this.setAction({
      scrollTop: 0
    })
  },


  upper(e) {
    // console.log(e)
  },


  lower(e) {
    // console.log(e)
  },


  scroll(e) {
    // console.log(e)
  },
  tap() {
    for (let i = 0; i < order.length; ++i) {
      if (order[i] === this.data.toView) {
        this.setData({
          toView: order[i + 1],
          scrollTop: (i + 1) * 200
        })
        break
      }
    }
  },


  tapMove() {
    this.setData({
      scrollTop: this.data.scrollTop + 10
    })
  },

(3).wsxx文件:

css 复制代码
.posList {
  position: fixed;
  left: 0%;
  top: 16%;
  width: 100%;
  height: 90%;
  background-color: rgb(215, 253, 0);
}


.scroll-view_H {
  white-space: nowrap;
}


.scroll-view-item {
  height: 100%;
}


.scroll-view-item_H {
  display: inline-block;
  width: 100%;
  height: 100%;
}
相关推荐
耀耀切克闹灬2 小时前
Skyline 渲染问题记录以及总结
微信小程序
小程序开发X3 小时前
2026 深圳 APP 开发甄选:技术架构搭建、全流程落地、综合选型解读
微信小程序·小程序·app开发
Kingexpand_com4 小时前
培训机构排课管理小程序设计与功能实现思路
小程序·软件开发·小程序定制开发·培训排课·培训机构·排课小程序
EatFan6 小时前
一个二维码背后的系统设计:批次生成、绑定、扫码与数据统计怎么做?
java·后端·微信小程序·二维码·qrcode
扶风ff8 小时前
练题簿企业培训方案:统一题库、在线任务与岗位考核
学习·小程序
AI行业应用研究8 小时前
会务问答机器人落地拆解:三级路由、知识库组织与防幻觉——会务小程序能自己回答参会者提问吗?
大数据·人工智能·安全·小程序·架构
盟道科技9 小时前
小程序订阅消息大规模投递实践:频控令牌池、Redis限流与失败补偿设计
分布式·算法·小程序
m0_587383009 小时前
本地同城无人机作业接单系统源码:架构拆解与抢单调度实现
java·小程序·架构·需求分析
2501_915909069 小时前
怎么用 FlutterFlow 把应用发布到 App Store?
android·ios·小程序·https·uni-app·iphone·webview
白远山1 天前
家政服务家政社区派单实战:调度系统架构设计与实现指南
java·开发语言·小程序·架构·需求分析