【问题标题】:Vue3 Functional Component render function Primevue TooltipVue3 功能组件渲染函数 Primevue Tooltip
【发布时间】:2022-10-16 14:42:48
【问题描述】:
rowTooltip: (createElement, cell, property, context) => {
            return withDirectives(createElement("div",  "any value"), ["tooltip", "is this the tooltip value?", "is this the value actually?", "no this is the value argument"]);
        },

如何呈现此工具提示指令:https://www.primefaces.org/primevue/tooltip

在带有 vue3 的功能组件内的渲染函数循环内。

我已经尝试了几个小时

为我的问题添加了一个叉子

【问题讨论】:

    标签: javascript vue.js vuejs3 primevue


    【解决方案1】:

    vue3有功能H

    使用设置功能:

    setup() {
      const tooltip = resolveDirective('tooltip');
    
      return () => {
        const vnode = withDirectives(
          h(Button, { label: "I'am dynamic button, hover me too" }),
          [[tooltip, 'tooltip directive with render function']]
        );
    
        return vnode;
      };
    }
    

    例如:https://stackblitz.com/edit/vue-gg76si?file=src/main.js

    【讨论】:

    • 谢谢你的回答 - 这很有效 - 正如你的例子所示。我已将“h”重命名为“createElement”,而当我尝试这样做但在功能组件的渲染函数内部时(在适当的上下文中不再有“this”),导入问题时会出现我的问题理论上,我的组件不再能够访问我在实例化应用程序时拥有的“PrimeVue”——因为我的功能组件是一个独立的实例。有什么想法吗?
    • stackblitz.com/edit/vue-6yjp8d?file=src/components/…添加了我自己的项目分支来模拟我的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-09
    • 2020-03-26
    • 2023-04-11
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 2021-06-08
    相关资源
    最近更新 更多