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

1.自定义组件生命周期函数:
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定义的列表样式:
<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:
  <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文件:
  
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文件:
.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%;
}

相关推荐

  1. 程序map如何使用?

    2023-12-09 12:12:02       58 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-09 12:12:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-09 12:12:02       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-09 12:12:02       82 阅读
  4. Python语言-面向对象

    2023-12-09 12:12:02       91 阅读

热门阅读

  1. postgresql12配置主从

    2023-12-09 12:12:02       44 阅读
  2. 【flutter压缩Uint8List图片大小】

    2023-12-09 12:12:02       61 阅读
  3. AIGC: 关于ChatGPT中实现一个聊天机器人

    2023-12-09 12:12:02       58 阅读
  4. .ros空间的清理

    2023-12-09 12:12:02       52 阅读
  5. centos7.9安装k8s v1.28.4

    2023-12-09 12:12:02       40 阅读
  6. ubuntu20.04设置开机自启动jar(依赖其他服务)

    2023-12-09 12:12:02       69 阅读
  7. SQL Server事务(Transaction)

    2023-12-09 12:12:02       55 阅读
  8. 【Docker】进阶之路:(十)Docker日志管理

    2023-12-09 12:12:02       42 阅读
  9. ffmpeg与opencv-python处理视频

    2023-12-09 12:12:02       57 阅读
  10. 鸿蒙(HarmonyOS)应用开发——http的使用

    2023-12-09 12:12:02       65 阅读
  11. LeetCode刷题笔记之链表

    2023-12-09 12:12:02       46 阅读