Skip to content

如何在Uniapp 的App端使用AntV F2 #2070

@willcong

Description

@willcong

因为直接用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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions