leaferjs / ui

一款好用的 Canvas 渲染引擎,革新的体验。高效绘图 、UI 交互(小游戏、互动应用、组态)、图形编辑。
https://www.leaferjs.com
MIT License
2.32k stars 81 forks source link

HTMLText在box内无法使用,特殊情况下可以生效 #154

Closed canbaoSama closed 2 months ago

canbaoSama commented 2 months ago

如果我在一个box里的children里使用HTMLText标签,则不能生效,会报错list$1[tag] is not a constructor { tag: 'HTMLText', text: 'Welcome to LeaferJS', }

但是如果我在这个页面添加如下的创建方式,则box里HTMLText又可以正常使用 const textL = new HTMLText({ text: <i style="color: red; font-weight: bold;">8</i>, })

请问大佬是不是引用有些问题啊

leaferjs commented 2 months ago

第一种情况,应该是没有引入html包造成的,注册HTMLText标签的函数在插件包中

canbaoSama commented 2 months ago

我引入了,第二种情况和第一种情况是在同一个页面,如果我添加了第二种情况的代码第一种也生效,但是不添加则第一种失败

leaferjs commented 2 months ago

import '@leafer-in/html'

这样引入

leaferjs commented 2 months ago

import { HTMLText } from '@leafer-in/html' 这样引入,没有实例化HTMLText,编译器不会把这个包的代码打包进来

canbaoSama commented 2 months ago

好吧,我傻了,忘记了