个人案例
- canvas父级标签通过wx:if控制后,canvas不显示了?
canvas父级标签通过wx:if或hidden控制后,canvas不显示了? [图片] import * as echarts from '../../components/ec-canvas/echarts'; var chart = null; Page({ data: { isModal: false, ec: { onInit: initChart }, }, showDetail: function (e) { const item = e.currentTarget.dataset.item; const index = e.currentTarget.dataset.index; item.grade = index + 1; this.setData({ rankDetail: item, isModal: true }); this._showChart() }, _showChart: function () { const option = { xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed'] }, yAxis: { type: 'value', }, grid: { y: 0, left: 0, containLabel: true, bottom: 0, top: 10, right: 0 }, series: [ { data: [120, 200, 150], type: 'bar', barWidth: '30%', barCategoryGap: '10%' } ] }; chart.setOption(option); }, }); function initChart(canvas, width, height, dpr) { chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr // new }); canvas.setChart(chart); return chart; }; <l-popup show="{{isModal}}" content-align="top" z-index="{{zIndex}}" bind:lintap="closeModal"> <view class="popup"> <view class="flex-column popup_ranking"> <text class="popup_ranking_name">{{rankDetail.title}}</text> <text class="popup_ranking_title">傻B行为指数榜</text> <view class="flex-column popup_vote"> <text>{{rankDetail.grade}}</text> <text>综合榜</text> </view> </view> <view class="flex-space canvas_case"> <view class="canvas"> <ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas> </view> <view class="canvas_tital"> <text class="tital_A">没做过</text> <text class="tital_B">偶尔做</text> <text class="tital_C">经常做</text> </view> </view> <button class="btn_detail" hover-class="btn_like" catchtap="toDetail">查看详情</button> </view> </l-popup>
2022-01-12 - Css transform 覆盖上层元素?
[图片] <view class="flex-center tab_bar" catchtap="toClassify"> <view class="flex-center to_class"> <text>{{ranking.classify}}</text> <text class="iconfont iconfont-right"></text> </view> </view> .tab_bar { width: 460rpx; height: 140rpx; position: fixed; bottom: 0; left: 0; right: 0; margin: 0 auto; z-index: 1; } .tab_bar::after { content: ''; width: 460rpx; height: 140rpx; background: #FFFFFF; border-radius: 40rpx 40rpx 0 0; transform: perspective(40px) scale(0.9) rotateX(20deg); filter: drop-shadow(0px -10px 29px rgba(0, 0, 0, 0.07)); box-sizing: border-box; position: absolute; bottom: 0; left: 0; right: 0; margin: 0 auto; z-index: 0; } .to_class { justify-content: center; font-size: 34rpx; font-weight: bold; color: #FA5136; position: absolute; left: 0; right: 0; bottom: 40rpx; margin: 0 auto; z-index: 9; transform: translateZ(1); }
2022-01-08 - 关于云函数工具类?
云开发环境共享时,想用一个通用方法调用资源方的资源,网上看到一个方法,说是写到工具类 请问,这个方法如何写到工具类啊。 //调用方新建函数:可放在工具类中,运行资源方云函数的通用函数 export async function runCloud(runName, data) { let c1 = new wx.cloud.Cloud({ appid: 'xxxxxxxx', // 资源方 AppID resourceAppid: 'xxxxxxxx', // 资源方环境 ID resourceEnv: 'xxxxxxxx', }) await c1.init() return await c1.callFunction({ name: runName, data: data, }) }
2021-12-29 - scroll-view组件的scroll-into-view属性获取不到元素id?
bindscroll="swichNav"函数获取不到元素id [图片] <scroll-view scroll-y="true" scroll-with-animation="true" refresher-enabled="true" enhanced="true" scroll-into-view="{{rowView}}" scroll-top="{{scrollTop}}" bindscroll="swichNav" class="task_view" style="height:{{menuHeight}}px"> <view class="item_scroll"> <block wx:for="{{task}}" wx:for-index="index" wx:key="item"> <text id="row_{{index}}" style="color: #ffffff;">{{item.time}}</text> <view wx:for="{{item.shop}}" wx:for-item="items" wx:key="item" class="shop"> <text>{{items.name}}</text> <text class="shop_order">20</text> <view class="flex-center shop_info"> <image class="avatar_35" mode="aspectFill" lazy-load="true" src="cloud://ohho-0g07i44qa70ce331.6f68-ohho-0g07i44qa70ce331-1304584431/icon/default_img.png"></image> <view class="flex-center"> <text>距您</text> <text>1230/m</text> </view> </view> </view> </block> </view> </scroll-view> bindscroll="swichNav"函数 swichNav: function (e) { console.log(e.currentTarget); },
2021-12-24 - scroll-view组件的scroll-into-view属性获取不到元素id?
bindscroll="swichNav"函数获取不到元素id [图片] <scroll-view scroll-y="true" scroll-with-animation="true" refresher-enabled="true" enhanced="true" scroll-into-view="{{rowView}}" scroll-top="{{scrollTop}}" bindscroll="swichNav" class="task_view" style="height:{{menuHeight}}px"> <view class="item_scroll"> <block wx:for="{{task}}" wx:for-index="index" wx:key="item"> <text id="row_{{index}}" style="color: #ffffff;">{{item.time}}</text> <view wx:for="{{item.shop}}" wx:for-item="items" wx:key="item" class="shop"> <text>{{items.name}}</text> <text class="shop_order">20</text> <view class="flex-center shop_info"> <image class="avatar_35" mode="aspectFill" lazy-load="true" src="cloud://ohho-0g07i44qa70ce331.6f68-ohho-0g07i44qa70ce331-1304584431/icon/default_img.png"></image> <view class="flex-center"> <text>距您</text> <text>1230/m</text> </view> </view> </view> </block> </view> </scroll-view> bindscroll="swichNav"函数 swichNav: function (e) { console.log(e.currentTarget); },
2021-12-24 - scroll-view组件的scroll-into-view属性获取不到元素id?
bindscroll="swichNav"函数获取不到元素ID [图片] <scroll-view scroll-y="true" scroll-with-animation="true" refresher-enabled="true" enhanced="true" scroll-into-view="{{rowView}}" scroll-top="{{scrollTop}}" bindscroll="swichNav" class="task_view" style="height:{{menuHeight}}px"> <view class="item_scroll"> <block wx:for="{{task}}" wx:for-index="index" wx:key="item"> <text id="row_{{index}}" style="color: #ffffff;">{{item.time}}</text> <view wx:for="{{item.shop}}" wx:for-item="items" wx:key="item" class="shop"> <text>{{items.name}}</text> <text class="shop_order">20</text> <view class="flex-center shop_info"> <image class="avatar_35" mode="aspectFill" lazy-load="true" src="cloud://ohho-0g07i44qa70ce331.6f68-ohho-0g07i44qa70ce331-1304584431/icon/default_img.png"></image> <view class="flex-center"> <text>距您</text> <text>1230/m</text> </view> </view> </view> </block> </view> </scroll-view> swichNav函数 swichNav: function (e) { console.log(e.currentTarget); }
2021-12-24 - 小程序 setData 重复执行?
在执行pickAttribute()函数时,为什么changeNumber()增加了setData函数,changeNumber()函数会自动执行,且重复执行。逻辑上这两个函数是不发生关系的。 [图片] pickAttribute: function (e) { if (this.data.tempOrder.count > 0 && this.data.goodsDetail.isAttribute) { console.log("968"); // this.checkingAttribute(); return }; if (this.data.tempOrder.count > 0 && !this.data.goodsDetail.isAttribute) { console.log("974"); this.setData({ showAttributes: true, }); return }; if (this.data.tempOrder.count <= 0) { console.log("982"); this.setData({ showAttributes: !this.data.showAttributes, }); return } }, changeNumber: function (e) { const count = e.detail.count; console.log("count(640) => ", count); const bindType = e.detail.type; const enter = e.detail.enter; const goods = (enter === 'Detail') ? this.data.goodsDetail : e.detail.goods; const isAttribute = goods.isAttribute; const inList = this.data.goodsList.findIndex(item => { return item._id === goods._id }); if (!isAttribute) { this.setData({ [`goodsList${inList}.count`]: count, 'goodsDetail.count': count, }); console.log("goodsDetail(651) => ", this.data.goodsDetail); }; **//为什么加了这行代码会重复执行** //this.setData({ // 'tempOrder.count': count //}); console.log("tempOrder(656) => ", this.data.tempOrder); }, [图片]
2021-12-18 - 关于 js 内存指针指向的问题?
有个联动的标签选择(如图) [图片] 例如:第一次选择了(["麻辣拌(无汤带麻酱)", "酸甜麻辣拌(无麻酱)"])两个属性后,如果取消了其中一个属性,那根据我的条件判断,应该是替换相应的值,而不是新增。现在出现的问题是,每次根据type类型查找下标,每次都是-1。 [图片] 代码 checkAttribute: function (e) { let pre = 0; let obj = {}; let tempArr = this.pureData.tempArr; const values = e.detail.value; console.log("values(1386) => ", values); const types = this.data.curAttributesType; const curAttributes = this.data.curAttributes; curAttributes.forEach(item => { const isExist = values.some(cur => cur === item.name) if (isExist) { item.checked = true; } else { item.checked = false; } }); const myAtr = curAttributes.filter(item => item.checked === true); obj.type = types; obj.value = myAtr; if (this.pureData.tempArr.length > 0) { const typeIdx = tempArr.findIndex(item => { item.type === this.data.curAttributesType }); console.log("typeIdx(1404) => ", typeIdx); if (typeIdx != -1) { this.pureData.tempArr[`${typeIdx}`].value = myAtr; } else { this.pureData.tempArr.push(obj) } } else { this.pureData.tempArr.push(obj); } console.log("tempArr(1412) => ", this.pureData.tempArr); this.setData({ curAttributes: curAttributes, }); },
2021-12-17 - 生活服务下的“跑腿”类目,是否可以申请长期订阅消息?
请问生活服务下的“跑腿”类目,是否可以申请长期订阅消息?
2021-12-03 - 转发时传json数据,安卓接收不到json?
转发时传json数据,ios可以接收到,但安卓(华为P9)接收不到json数据 ios [图片] 安卓(华为P9) [图片] const shareSignIn = { path: '/flockProfile/pages/flockProfile/flockProfile?groupInfo=' + JSON.stringify(this.data.groupInfo) + '&pathType=' + 'SignIn', imageUrl: '/images/share_img.png', title: '打开,完成群管理员认证' }; wx.setStorageSync('groupInfo', this.data.groupInfo); return (type === 'SignIn') ? shareSignIn : shareObj;
2021-11-29