提交 a04ce002 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

feat: 移除 createCanvasContextAsync 路由

上级 7c6eb5ef
<template>
<view>
<canvas class="child-canvas" id="canvas" style="height: 100px;border: 1px solid red;"></canvas> <view>isCanvasContextNull: {{isCanvasContextNull}}</view>
</view>
</template>
<script>
type getContext = {
ctx : boolean,
hasFillRect : boolean
}
export default {
data() {
return { isCanvasContextNull : false
}
},
mounted() {
this.$nextTick(() => {
uni.createCanvasContextAsync({
id: 'canvas',
component: this,
success: (res : CanvasContext) => {
const context = res.getContext('2d')!; this.isCanvasContextNull = true
// 若干绘制调用
// 绘制红色正方形
context.fillStyle = "rgb(200, 0, 0)";
context.fillRect(10, 10, 50, 50);
// 绘制蓝色半透明正方形
context.fillStyle = "rgba(0, 0, 200, 0.5)";
context.fillRect(30, 30, 50, 50);
context.draw();
}
})
})
}
}
</script>
\ No newline at end of file
const PAGE_PATH = '/pages/API/create-canvas-context-async/create-canvas-context-async'
describe('create-canvas-context-async', () => {
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('page canvas', async () => {
await page.waitFor(100)
const data = await page.data()
expect(data.testCreateCanvasContextAsyncSuccess).toBe(true)
})
it('component canvas', async () => {
// child-canvas
await page.waitFor(100)
// const element = await page.$('.node-child-component')
const element = await page.$('child-canvas')
const data = await page.data()
expect(data.isCanvasContextNull).toBe(true)
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册