antvis / antvis/F2

如何在Uniapp 的App端使用AntV F2

Open
#2,070 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8k
Forks
637
PR merge metrics
No merged PRs in 30d

Description

因为直接用f-vue,在app端遇到canvas的context报错问题。我目前对照f-vue项目中的index.ts文件,做了一个适配,但还是报错。该从哪里下手。
//#ifdef APP-PLUS
context = uni.createCanvasContext('f2-canvas-app', this);
returnObject = {
...props,
children: toRawChildren($slots),
};
//#endif
// #ifndef APP-PLUS
context = canvasEl.getContext('2d');
returnObject = {
...props,
// context 内部创建,不能被覆盖
context,
children: toRawChildren($slots),
};

错误信息:
14:29:04.655 TypeError: Cannot read property 'createElement' of undefined
14:29:04.655 [JS Framework] Failed to execute the callback function:
TypeError: Cannot read property 'createElement' of undefined
14:29:04.686 reportJSException >>>> exception function:__WEEX_CALL_JAVASCRIPT__, exception:JavaScript execute error!Uncaught TypeError: Cannot read property 'createElement' of undefined
at OffscreenCanvasCreator2.getOrCreateCanvas (app-service.js:126215:36)
at TextService2.measureFont (app-service.js:127302:58)
at TextService2.measureText (app-service.js:127364:35)
at TextUpdater2.update (app-service.js:125034:54)
at DefaultStyleValueRegistry2.updateGeometry (app-service.js:123935:37)
at DefaultStyleValueRegistry2.processProperties (app-service.js:123790:16)
at DefaultStyleValueRegistry2.recalc (app-service.js:123919:16)
at RenderingService2.renderDisplayObject (app-service.js:126368:49)
at (app-service.js:126393:17)
at RenderingService2.renderDisplayObject (app-service.js:126392:55)

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the f-vue project’s index.ts and the APP-PLUS canvas branch shown in the issue. Trace the reported OffscreenCanvasCreator2 and TextService2 stack to determine why createElement is unavailable in the Uniapp App environment; done means the integration no longer raises this error or the supported limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.