【问题标题】:Is there a way to open new tab in navigation bar for custom lightning component with record name as tab label?有没有办法在导航栏中为自定义闪电组件打开新选项卡,记录名称为选项卡标签?
【发布时间】:2019-04-05 14:32:07
【问题描述】:

我需要在非控制台应用程序环境中的 Lightning Experience 的导航栏中打开新的导航选项卡。选项卡应将记录名称预先填充为标签。

尝试了以下方法: 为目标闪电组件创建自定义选项卡

在源组件中:

创建的页面引用类型为standard__navItemPage。 为目标组件指定自定义选项卡名称的属性。 使用导航服务将控件重定向到新的 URL。

在目标组件中: 使用接口isUrlAddressable获取页面参数。

var pageReference = {
                    type: 'standard__navItemPage',
                    attributes: {
                        apiName: 'Product_Overview',
                    },
                    state: {
                        c__productId: itemId,
                        c__isfavourite : isfavourite,
                        c__isSourceSearchResultCmp : false                            
                    }
                };   
         var navService = component.find("navService");
         navService.generateUrl(pageReference)
         .then($A.getCallback(function(url) {
             console.log('Using Navigate'+url);
             navService.navigate(pageReference);
         }), $A.getCallback(function(error) {
             console.log(error);
         }));

问题是,打开的导航选项卡没有记录名称等详细信息,我找不到任何相同的 API 或方法。

如有任何指导,我们将不胜感激。

【问题讨论】:

    标签: salesforce salesforce-lightning lightning


    【解决方案1】:
    var pageReference = {
        type: 'standard__navItemPage',
        attributes: { 
            apiName: 'Product_Overview', 
        },
        state: { 
            c__productId: itemId,
            c__isfavourite : isfavourite,
            c__isSourceSearchResultCmp : false
        }};
        var navService = component.find("navService");
        navService.generateUrl(pageReference).then($A.getCallback(function(url) { 
            console.log('Using Navigate'+url); 
            //---add this line which allows you to open url in new tab instead of navService 
            window.open('https:'+url,
                        '_blank' // <- This is what makes it open in a new window.
                       );
        }),$A.getCallback(function(error) {
        console.log(error); 
    }));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-14
      • 2022-01-19
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      相关资源
      最近更新 更多