- Component自定义组件中methods的this指向问题
import { getLoginCode, login } from "../../api/index"; import { TOKEN } from "../../constant/index"; const app = getApp(); Component({ data: { hidden: true, height: "0%", padding: "0rpx", logo: "", appName: "", isAgree: false, }, properties: {}, observers: { hidden: function (hidden) { if (!hidden) { this.setData({ height: "68%", padding: "24rpx", logo: app.globalData.appConfig.logo, appName: app.globalData.appConfig.app_name, }); } }, }, methods: { onShowLogin: function () { this.setData({ hidden: false, }); }, onHiddenLogin: function () { console.log(this); this.setData({ hidden: true, height: "0%", padding: "0rpx", logo: "", appName: "", isAgree: false, }); }, onAgree: function () { this.setData({ isAgree: !this.data.isAgree }); }, onAgreement: function () { console.log("协议"); }, onLogin: async function () { if (!this.data.isAgree) return wx.showToast({ title: "请先勾选同意", icon: "none", duration: 1500, }); const loginCode = await getLoginCode(); const payload = { code: loginCode, appid: app.globalData.appConfig.appid, secret: app.globalData.appConfig.appsecret, key: app.globalData.appConfig.key, }; const { code, data } = await login(payload); if (code !== 0) return; wx.setStorageSync(TOKEN, data); this.onHidden(); this.onEmit(); }, onEmit: function () { // 执行父组件传递过来的方法 this.triggerEvent("onEmit"); }, }, options: { styleIsolation: "apply-shared", }, });
2023-11-20 - 获取access_token填写client_credential?
auth.getAccessToken接口所必传的参数grant_type在哪获取?
2022-08-15 - 在编写input输入框时,如何实现字母和数字组合?
在编写input输入框时,如何实现字母和数字组合? <input class="weui-input" maxlength="5" type="number" placeholder="请输入工号" />
2021-04-18