当前位置: 首页 > news >正文

结合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%;
}

相关文章:

  • 公有云迁移研究——AWS Route53
  • el-table全部选择和全部取消
  • 源码安装git
  • 蓝牙物联网对接技术难点有哪些?
  • 【clickhouse】ck远程访问另一个ck
  • SpringDataJPA基础
  • 管理空闲存储空间
  • No suitable driver found for jdbc:mysql://localhost:3306(2023/12/7更新)
  • GO设计模式——12、外观模式(结构型)
  • 【Go语言分析 select case 】
  • 力扣题:字符的统计-12.4
  • JVM 运行时参数
  • 高级系统架构设计师之路
  • 物理结构设计要点
  • 约瑟夫生死游戏
  • office办公技能|ppt插件使用
  • 前端笔记(四)Flex 布局
  • java WebSocket带参数处理使用
  • 佳明(Garmin) fēnix 7X 增加小睡检测功能
  • 在windows下编译libiconv库
  • 巴基斯坦军方:印度导弹袭击巴首都附近空军基地
  • 4月证券私募产品备案量创23个月新高,股票策略占比超六成
  • 告别户口本!今天起婚姻登记实现全国通办
  • “浦东时刻”在京展出:沉浸式体验海派风情
  • 全国人大常委会启动食品安全法执法检查
  • 李彦宏:技术迭代速度之快从业30年来未见过,要提升执行力战胜对手