- 如何在this.data.array.forEach内部读取this.data.XXX?
大家好: this.data.array.forEach(function (item) { console.log(this.data.XXX); }); 报错,提示: TypeError: Cannot read property 'data' of undefined 请问这是什么原因导致的呢? 可以在this.data.array.forEach内部读取this.data.XXX吗?正确的方式应该怎么做呢? 谢谢!
2023-02-18 - onLoad里的item来自哪里?
新年快乐朋友们! 我在调试这个onLoad函数时,发现这行代码里的item数据有问题;我想追溯item的源头,但是我不知道item来自哪里。 它在哪里? 谢谢!
2023-01-21 - 如何用wxss,把flex里的image位置右对齐?
这是wxml: <view class="container"> <view class="item1"> {{'内容一'}} <view class="item2">内容二</view> <image class="item3" src="/assets/common/more.svg" /> </view> </view> 这是wxss: .container { padding: 60rpx 50rpx 0; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; background-color: lightpink; } .item1 { color: #000; font-size: 54rpx; font-weight: 500; align-self: flex-start; width: 100%; position: relative; background-color: rgb(196, 130, 130); } .item2 { display: inline-block; box-sizing: border-box; color: #fff; padding: 6rpx 14rpx; font-size: 20rpx; font-weight: normal; border-radius: 20rpx; text-align: center; line-height: initial; margin-left: 16rpx; } .item3 { transform: rotate(90deg); width: 37rpx; height: 37rpx; } 目前效果如图: [图片] 想要的效果是把item3右对齐,而item1和item2不变,如图: [图片] 请问我该如何实现呢?谢谢!
2022-11-18 - 初学小程序,测试switch,ReferenceError: XXX is not defined?
初学小程序,测试switch。新建项目,然后修改app.json,添加: "useExtendedLib": { "weui": true }, "usingComponents": { "mp-cells": "weui-miniprogram/cells/cells", "mp-cell": "weui-miniprogram/cell/cell", "mp-form": "weui-miniprogram/form/form" } 修改index.wxml: <!--index.wxml--> <mp-cell title="测试" ext-class=""> <switch slot="footer" bindchange="bindSwitchChange" /> </mp-cell> 修改index.js: // index.js Page({ data: { shouldTest: true }, bindSwitchChange(e) { this.setData({ shouldTest: e.detail.value }); console.log(shouldTest); } }) 然后报错: ReferenceError: shouldTest is not defined at zo.bindSwitchChange (index.js? [sm]:9) at Object.i.safeCallback (WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1) at WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 at Cn (WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1) at WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 at oe (WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1) at ie (WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1) at WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 at WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 at o.emit (WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1)(env: macOS,mp,1.06.2209190; lib: 2.27.0) errorReport @ WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 thirdErrorReport @ WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 (anonymous) @ WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 (anonymous) @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 i.safeCallback @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 i.call @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 message @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 i.safeCallback @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 (anonymous) @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 Cn @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 (anonymous) @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 oe @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 ie @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 (anonymous) @ WASubContext.js?t=wechat&s=1667317212484&v=2.27.0:1 (anonymous) @ WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 emit @ WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 dispatch @ WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 cb @ WAServiceMainContext.js?t=wechat&s=1667317212484&v=2.27.0:1 a @ VM146 asdebug.js:10 c @ VM146 asdebug.js:10 (anonymous) @ VM146 asdebug.js:1 f @ VM146 asdebug.js:1 g @ VM146 asdebug.js:1 (anonymous) @ VM146 asdebug.js:1 _ws.onmessage @ VM146 asdebug.js:1 请问我的问题出在哪里呢?谢谢!
2022-11-02