Props、emit
Siona
Props、emit
emit
父组件 / 通过 createApp() 挂载组件的 js、ts
<script setup lang="ts">
const render = (lf, toolOverlay) => {
this.lfContainer = toolOverlay;
// 自定义 insert 点击事件
lf.on('custom:insert-click', (data: any) => {
console.log(333, data);
})
}
</script>
子组件
<script setup lang="ts">
const props = defineProps<{
model: any,
graphModel: any
isSelected: any,
isHovered: any,
disabled: any,
properties: any
}>();
// 添加下一个节点
const handleNext = () => {
console.log('this.graphModel --->>>', props.graphModel)
const nodeX = props.model.x
const nodeY = props.model.y
const x = nodeX + props.model.width / 2
const y = nodeY
// 方式一:调用注册到 lf 组件的 Popover 插件中的方法,来显示 Popover 弹窗
// props.graphModel.popover.show({
// width: 16,
// height: 16,
// x,
// y,
// })
// 方式二:通过自定义事件实现透传,来显示 Popover 弹窗
props.graphModel.eventCenter.emit('custom:insert-click', props.model);
}
</script>