小游戏中,wx.createUserInfoButton创建的按钮在真机中无法展示?
发布于 5 年前 作者 ishen 15066 次浏览 来自 官方Issues

在开发者工具(基础库:2.2.5)中能正常展示,但是真机(基础库:2.10.1)中展示不出来。求指导,代码如下:

var button = wx.createUserInfoButton({
    type: 'text',
    text: "开始游戏",
    style: {
        left: wx.getSystemInfoSync().screenWidth / 2 - 60,
        bottom: wx.getSystemInfoSync().screenHeight / 2 - 60,
        width: 120,
        height: 40,
        lineHeight: 40,
        backgroundColor: '#fb94a9',
        color: '#ffffff',
        textAlign: 'center',
        fontSize: 16,
        borderRadius: 20
    }
});

button.show();

button.onTap(res => {
    if (res.errMsg === "getUserInfo:ok") {
        console.log("已经授权");
        button.destroy();
    } else {
        console.log("没有授权")
    }
});
1 回复

谢邀,老哥,没搞过小游戏。不过我试试看吧。

问题应该是 style里 不能使用变量去计算。

回到顶部