- 类型{}上不存在属性”windowWidth“?
在onLoad()里面已经将windowWidth保存到data中,在滚动事件的代码中写代码,war width=this.data.windowWidth,却报错提示,类型{}上不存在属性”windowWidth“.如果在滚动事件代码中把onLoad中的代码:var systemInfo = systemInfo.windowWidth var windowWidth = systemInfo.widowWidth;var width = windowWidth,写进去,就不会报这样的错,这是生命原因?如果多个地方需要用到这个属性,那不是每次都得重新写一遍? onLoad() { var systemInfo=wx.getSystemInfoSync(); var windowHeight = systemInfo.windowHeight; var windowWidth = systemInfo.windowWidth; var width = windowWidth; var height = 100; var radius = (height/2)+(width*width/8/height); var left = -(radius-width/2); this.setData({ windowHeight:windowHeight, windowWidth:windowWidth, radius:radius, left:left }) }, /** * 滚动的事件 */ scrollEvent:function(event:any){ var scrollTop = event.detail.scrollTop; if(scrollTop > 0 && scrollTop <= 100){ var height = 100-scrollTop; var width = this.data.windowWidth; // var systemInfo=wx.getSystemInfoSync(); // var windowWidth = systemInfo.windowWidth; // var width = windowWidth; var radius = (height/2)+(width*width/8/height); var left = -(radius-width/2); this.setData({ radius:radius, left:left }) } },
2023-09-19 - 已声明datawet,但从未读取其值,这是什么问题?
如下面的代码,写了一个跳转的代码,我之前也是这样写,怎么就从来没有遇到过如图所示的问题,是不是小程序又改了? ts代码: onshijian(e){ console.log(e); var dataset=e.currentTarget.dataset; wx.navigateTo({ url:'/pages/abc/abc' }) }, 问题如图: [图片]
2023-05-09 - 怎么又要让我续费呢?
10月19日晚上续的费用,才4号,怎么就又要让我续费呢?难道有效期只有半个月?请官方回复 [图片]
2022-11-05 - wx.login做了个全局配置,不知道有没有问题?
自从官方说改了授权接口之后,花了不少时间研究这个东西,也查了不少资料,也得到过不少人的指点,今天终于实现了效果,终究是自己第一次完成了这么个功能,不知道代码有没有问题,请大师给参考下。另外就是头像URL和数据库中的URL不一样,是不是要自己重新设置存储URL? [图片] login文件代码: wxml代码: <form catchsubmit="formSubmit"> <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar"> <image class="avatar" src="{{avatarUrl}}"></image> </button> <view class="row"> <view class="text">用户名</view> <input type="nickname" class="weui-input" placeholder="请输入昵称"/> </view> <button class="for-button" type="primary" formType="submit">授权</button> </form> js代码: const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0' const db = wx.cloud.database(); const app=getApp(); Page({ /** * 页面的初始数据 */ data: { avatarUrl: defaultAvatarUrl, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, onChooseAvatar(e) { // console.log(e); const { avatarUrl } = e.detail this.setData({ avatarUrl, }) }, formSubmit(e){ wx.login({ success (res) { // console.log(res); const code=res.code; if (code) { app.setcode(code); db.collection("user").add({ data:{ code: res.code, avatarUrl:defaultAvatarUrl, } }) wx.showToast({ title:"恭喜!授权成功!" }); setTimeout(()=>{ wx.navigateBack({}); },1500) } else { console.log('登录失败!' + res.errMsg) } } }) }, app.js代码: //app.js App({ onLaunch: function () { if(!wx.cloud){ console.error('请使用2.2.3或以上的基础库以使用云能力') }else{ wx.cloud.init({ traceUser:true, }) } // 展示本地存储能力 const logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) wx.setStorageSync('logs', logs) this.globalData={} this.loadcode(); }, //判断是否已经授权 loadcode:function(){ const that=this; wx.getSetting({ success:res=>{ const iscode=res.authSetting['scope.code']; if(iscode){ wx.code({ success:res=>{ const code=res.code; that.globalData.code=code; } }) } } }) }, //用户授权 is_login: function(){ if(this.globalData.code){ return true; }else{ return false; } }, setcode:function(code){ this.globalData.code=code; }, })
2022-09-27 - 用wx.login修改授权接口?
之前是用wx.getuserinfo做的用户授权,因为这些接口都要被废弃,所以就用wx.login改接口,现在问题是,有些地方我需要判断用户有没有授权,但是点击授权,提示说授权成功,但是再次打开页面时还会弹出窗口。这个授权做是全局配置,在页面中引用,还有就是头像图片能够插入到数据库中,用户名没有插入。 [图片][图片][图片] login文件代码(授权页面): <form catchsubmit="formSubmit"> <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar"> <image class="avatar" src="{{avatarUrl}}"></image> </button> <view class="row"> <view class="text">用户名</view> <input type="nickname" class="weui-input" placeholder="请输入昵称"/> </view> <button type="primary" style="margin-top:40rpx;margin-bottom: 20rpx;" formType="submit">授权</button> </form> js代码: const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0' const db = wx.cloud.database(); const app=getApp(); Page({ /** * 页面的初始数据 */ data: { avatarUrl: defaultAvatarUrl, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, onChooseAvatar(e) { // console.log(e); const { avatarUrl } = e.detail this.setData({ avatarUrl, }) }, formSubmit(e){ console.log(e); const nickName=e.detail.value.nickName; wx.login({ success (res) { console.log(res); if (res.code) { db.collection("user").add({ data:{ code: res.code, avatarUrl:defaultAvatarUrl, nickName:nickName } }) wx.showToast({ title:"恭喜!授权成功!" }); setTimeout(()=>{ wx.navigateBack({}); },1500) } else { console.log('登录失败!' + res.errMsg) } } }) }, app.js代码: //app.js App({ onLaunch: function () { if(!wx.cloud){ console.error('请使用2.2.3或以上的基础库以使用云能力') }else{ wx.cloud.init({ traceUser:true, }) } // 展示本地存储能力 const logs = wx.getStorageSync('logs') || [] logs.unshift(Date.now()) wx.setStorageSync('logs', logs) this.globalData={} this.loadlogin(); }, //判断是否已经授权 loadlogin:function(){ const that=this; wx.getSetting({ success:res=>{ const islogin=res.authSetting['scope.login']; if(islogin){ wx.login({ success:res=>{ const login=res.login; that.globalData.login=login; } }) } } }) }, //用户授权 is_login: function(){ if(this.globalData.login){ return true; }else{ return false; } }, setUserInfo:function(login){ this.globalData.login=login; } })
2022-09-25 - 获取用户信息,修改用户信息?
用getUserInfo获取用户信息,显示的是匿名用户信息,只要授权了,就不会再次要求授权,用wx.getUserProfile获取用户信息,每次进入页面就需要进行一次授权。在修改用户资料页面,console.log出来是信息没有id,那么要修改用户信息,怎么知道修改的是个用户的信息?要怎么获取?在网上查找资料,要么用的是插件,要么就是不全,查官方文档,又要改接口,对于我们初学者来说,头痛。 [图片][图片] 代码片段 https://developers.weixin.qq.com/s/nmxH4smH7pCS
2022-09-22 - 跳转到详情页,首页跳转报错,二级页面能够正常跳转?
列表信息布局是在components中,分别在首页和二级分类页面中展示,详情页布局都是一样的,所有想把首页和分类页的列表信息跳转到一个详情页面当中。在跳转时,首页报错如图,二级页面能够正常跳转。 [图片] 首页代码: <segment items="{{items}}" defaultIndex="0" bind:itemchanged="onSegmentItemChanged"> <view slot="0" class="segment-page work-page"> <recruitment wx:for="{{recruits}}" wx:key="key" wx:for-item="recruit" recruit="{{recruit}}" detailurl="../recuitmentd/recuitmentd?index={{index}}"></recruitment> </view> </segment> 分类页代码 <recruitment wx:for="{{recruits}}" wx:key="key" wx:for-item="recruit" recruit="{{recruit}}" detailurl="../../recuitmentd/recuitmentd?index={{index}}"></recruitment> 详情页js代码 onLoad(options) { console.log(options); let index = options.index; let pages = getCurrentPages(); let indexpage = pages[0]; if(pages.length > 0){ indexpage = pages[1] } let recruits = indexpage.data.recruits; let recruit = recruits[index]; this.setData({ index:index, })
2022-09-16 - 为什么分类页面的列表信息跳转详情页,返回的是首页的列表第一条信息?
首页是集合所有数据信息,分类页面是按条件查询的数据信息,列表信息布局做成components组件,首页列表信息跳转详情页正常,分类页面跳转详情页,只有第一天有点击事件,其他的点击没有反应,导出来却是首页第一条的详情页的信息。 [图片][图片][图片] components中的代码: wxlm代码: <navigator url="{{detailurl}}"> <view class="list-group"> <view class="list-title">自动化装配钳工</view> 为了减少代码过多,中间布局部分删除了 </view> </navigator> js代码: Component({ /** * 组件的属性列表 */ properties: { detailurl:{ type:String, value:null }, recruit:{ type:Object, value:{} }, type:{ type:String, value:"" } }, page页面代码: 首页跳转页面js代码: if(index===1){ wx.navigateTo({ url:"../index/recruitwhole/recruitwhole?type="+index, }) }if(index===2){ wx.navigateTo({ url:"/pages/index/recruittemporary/recruittemporary?type="+index, }) } 全职招聘分类页面wxml代码: <recruitment wx:for="{{recruits}}" wx:key="key" wx:for-item="recruit" recruit="{{recruit}}" type="whole" detailurl="../../recuitmentd/recuitmentd?type={{type}}&index={{index}}" ></recruitment> 全职招聘分类页面JS代码: onLoad: function (options) { const type = options.type; this.setData({ type:type }) }, 详情页js代码: onLoad(options) { console.log(options); const index = options.index; const pages = getCurrentPages(); const indexpage = pages[0]; const recruits = indexpage.data.recruits; const recruit = recruits[index]; }
2022-09-13 - 多个页面的列表信息跳转到同一个详情页面,如何做区分?
今天这里提两个问题,第一个问题坑了我好长时间,就是页面所有点击事件失效,我尝试着增加一个文字添加点击事件看看能不能点击,结果一样无效,我就把所有代码全部注释,结果文字点击事件生效了,经过不断测试,就是一张图片的代码,注释了,点击事件生效,不注释,所有点击事件失效,问题如截图所示,在首页也有这样的一段代码,却没有任何影响,这是什么问题? 第二个问题,就是图中红色框中的列表信息都是跳转到一个详情页面,但是其他的跳转后都是显示了首页的信息,这个要怎么做区分? [图片][图片] components组件代码: <navigator url="{{detailurl}}"> <view class="list-group"></view> </navigator> js代码: properties: { detailurl:{ type:String, value:"" }, recruit:{ type:Object, value:"" } }, pages页面代码: 全职招聘分类wxml代码: <wxs src="../../../utils/util.wxs" module="util" /> <view class="content"> <view class="search-group"> <view class="search-input-group"> <icon type="search" class="search-icon" size="20px"></icon> <input class="search-input" placeholder="请输入关键字" placeholder-class="placeholder-input" value="{{value}}" ></input> <icon type="clear" class="clear-icon" size="20px" bind:tap="onClearEvent"></icon> </view> <text>搜索</text> </view> <!-- <view class="ad-group"> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png"></image> </view> --> 这段被注释的就是图片代码 <select></select> <view bind:tap="detailEvent">跳转详情页</view> <recruitment wx:for="{{recruits}}" wx:key="key" wx:for-item="recruit" recruit="{{recruit}}" open-type="navigate" detailurl="/pages/recuitmentd/recuitmentd?index={{index}}"></recruitment> <loadingmore hasmore="{{hasmore}}"></loadingmore> </view> 详情页js代码: onLoad(options) { console.log(options); const index = options.index; const pages = getCurrentPages(); const indexpage = pages[0]; const recruits = indexpage.data.recruits; const recruit = recruits[index]; },
2022-09-12 - components组件在多个页面中使用,但是navigator跳转转时点击没有反应?
犹豫首页显示的是所有信息的列表,再做了几个分类页面,所有把信息做成了components组件,在各个分类页面展示,但是在跳转到详情页面时,首页的信息能够跳转,分类页面的信息点击没有反应,更别说跳转了,这个问题怎么解决?问题展示如图: [图片][图片] 代码: components组件代码: <wxs src="../../utils/util.wxs" module="util"/> <navigator url="{{detailurl}}"> <view class="list-group"> <view class="list-title">自动化装配钳工</view> <view class="content">{{recruit.content}}</view> <view class="nickName"> <image class="nickName-avatar" src="{{recruit.author.avatarUrl}}"> </image> <view class="nickName-company"> <view class="company">深圳市赢世纪科技有限公司</view> <view class="nickName-firstName"> <view class="firstName">{{recruit.firstName}}</view> <view class="spot">·</view> <view class="position">人事经理</view> </view> </view> <button class="varchar"> <image class="varchar-image" src="/images/telephone.png"></image> <text class="varchar-text">电话</text> </button> </view> <view class="list-detail"> <view class="detail-location"> <image class="location" src="../../images/location.png"/> <text class="location-text">{{recruit.location.address}}</text> </view> <view class="detail-time">{{util.timeFormat(recruit.create_time)}}</view> </view> </view> </navigator> components组件js代码: properties: { detailurl:{ type:String, value:null }, recruit:{ type:Object, value:{} } }, page首页代码: wxml代码: <recruitment wx:for="{{recruits}}" wx:key="key" wx:for-item="recruit" recruit="{{recruit}}" detailurl="../recuitmentd/recuitmentd?index={{index}}"></recruitment> </view> page分类项页面代码: <recruitment wx:for="{{recruits}}" wx:key="key" wx:for-item="recruit" recruit="{{recruit}}" detailurl="../../recuitmentd/recuitmentd?index={{index}}"></recruitment>
2022-09-11