小游戏网络图片真机预览多重影分身
发布于 5 年前 作者 gang08 9968 次浏览 来自 问答

game.js

import ‘./js/libs/weapp-adapter’

console.log(canvas.width, canvas.height)

var context = canvas.getContext(‘2d’)

var image = wx.createImage()

image.onload = function () {

  context.drawImage(image, 100, 100)

}

let button = wx.createUserInfoButton({

  type: ‘text’,

  text: ‘登录’,

  withCredentials:false,

  style: {

    left: 80,

    top: 500,

    width: 200,

    height: 40,

    lineHeight: 40,

    backgroundColor: ‘#ff00aa’,

    color: ‘#ffffff’,

    textAlign: ‘center’,

    fontSize: 16,

    borderRadius: 4

  }

})

button.onTap((res) => {

  console.log(res)

  var imageUrl = res.userInfo.avatarUrl

  image.src = imageUrl

})

2 回复

也遇到这个问题,有解决的么?   貌似每次清空canvas可以解决一部分,但是会有其他问题

回到顶部