如何在showModal控制器中获取post-id和user?

这是我的初始化程序:

export default {
    name: 'customInit',
    initialize() {      
        withPluginApi('0.8.7', api => {             
            api.attachWidgetAction('post', 'showCustomModal', () => {
                const modal = showModal('customModal');
            });
                
            api.addPostMenuButton('customBtn', (attrs) => {                
                return {
                    data: {
                        "post-id": attrs.id,
                        "user": attrs.username
                    },
                    action: 'showCustomModal',
                    icon: 'hand-holding-usd',
                    className: 'custom-btn',
                    title: 'custom_icon_anchor',
                    position: 'first' 
                };
            });
        });
    }
};

它能正确显示我的模态框,但我想知道如何根据点击的自定义帖子菜单按钮来传递我的 post-id 和 user。我已经在 Github 上搜索了好几个小时,但仍然不明白如何能将这些传递给我的 Custom Modal Controller。

2 个赞