Layout 报错提示 Please set width and height ?
发布于 2 年前 作者 lxia 12924 次浏览 来自 问答

minigame-canvas-engine 插件

一直报错如下:

以下是开放数据域 index.js的代码:

const Layout = requirePlugin(‘Layout’).default;

let template = `

<view >

  <text value=“hello canvas”> </text>

</view>

`

let style = {

container: {

	width: 200,

	height: 100,

	backgroundColor: '\#ffffff',

	justContent: 'center',

	alignItems: 'center',

},

testText: {

	color: '\#ff0000',

	width: 200,

	height: 100,

	lineHeight: 100,

	fontSize: 30,

	textAlign: 'center',

}

}

wx.onMessage(data => {

Layout.init(template, style);

let canvas = wx.getSharedCanvas();

canvas.width = 200;

canvas.height = 100;

Layout.updateViewPort({

	width: 200,

	heigth: 100,

	x: 100,

	y: 100

  })

let context = canvas.getContext('2d');

Layout.layout(context);

});

回到顶部