HumanBreak/docs/api/class/m-component.md
2024-03-01 19:52:30 +08:00

3.0 KiB
Raw Blame History

类 MComponent

渲染进程类,游戏进程不能直接使用。对于部分方法,请参考 UI 编写

content

declare var content: any[]
  • 成员说明

    存储了当前组件的所有内容

defineProps()

declare function defineProps(props: Record<string, any>): this

defineEmits()

declare function defineEmits(emits: string[]): this

div()

declare function div(children?: any, config?: any): this

span()

declare function span(children?: any, config?: any): this

canvas()

declare function canvas(config?: any): this

text()

declare function text(text: string | (() => string), config?: any): this

com()

declare function com(component: any, config?: any): this

vfor()

declare function vfor(items: any, map: (value: any, index: number) => VNode): this

h()

declare function h(type: any, children?: any, config?: any): this

onSetup()

declare function onSetup(fn: OnSetupFunction): this

onMounted()

declare function onMounted(fn: OnMountedFunction): this

setup()

declare function setup(fn: SetupFunction): this

ret()

declare function ret(fn: RetFunction): this

export()

declare function export(): Component

mountNum

declare var mountNum: number

vNodeS()

declare function vNodeS(child: any, mount?: number): VNode
  • 静态方法说明

    将单个渲染内容输出为单个 VNode

vNodeM()

declare function vNodeM(mc: MComponent, mount?: number): VNode[]
  • 静态方法说明

    将一个 MComponent 组件渲染为一个 VNode 数组

vNode()

declare function vNode(children: any, mount?: number): VNode[]
  • 静态方法说明

    将一系列渲染内容输出为一个 VNode 数组

unwrapProps()

declare function unwrapProps(props?: Record<string, () => any>): Record<string, any>
  • 静态方法说明

    获取 props 的真实值。因为传入渲染内容的 props 是一个函数,因此需要一层调用

prop()

declare function prop(component: Component, props: Record<string, any>): VNode
  • 静态方法说明

    在渲染时给一个组件传递 props。实际效果为在调用后并不会传递当被传递的组件被渲染时将会传递 props。