[英]R shiny - Add logo in browser window using titlePanel
I want to add a logo to the browser window in the same way as all browser windows are usually displayed:我想以与通常显示所有浏览器 windows 相同的方式向浏览器 window 添加徽标:
titlePanel
allows to add easily images to the application title, by using: titlePanel(title = div(img(src="myAppImage.jpg"), "My App Name")
It is also possible to add the title that should be displayed by the browser window with windowTitle
as a parameter. titlePanel
允许通过以下方式轻松地将图像添加到应用程序标题: titlePanel(title = div(img(src="myAppImage.jpg"), "My App Name")
也可以添加应显示的标题以 windowTitle 作为参数的浏览器windowTitle
。
However, it does not work when adding an image to the browser window.但是,将图像添加到浏览器 window 时不起作用。 I tried:
titlePanel(title = div(img(src="myAppImage.jpg"), "My App Name"), windowTitle = div(img(src="myBrowserImage.png"), "My Browser Name"))
.我试过:
titlePanel(title = div(img(src="myAppImage.jpg"), "My App Name"), windowTitle = div(img(src="myBrowserImage.png"), "My Browser Name"))
。 But this gives the following browser name: <img src...>但这给出了以下浏览器名称:<img src...>
What is the correct way of writing it?正确的写法是什么?
Not inside the titlePanel
but you can add following inside the ui:不在
titlePanel
内,但您可以在 ui 内添加以下内容:
tags$head(
tags$link(rel = "icon", type = "image/png", sizes = "32x32", href = "/myBrowserImage.png"))
Also you should put the image inside www
folder.另外,您应该将图像放在
www
文件夹中。
As @phago29 indicated, one way to write it is:正如@phago29 所指出的,一种写法是:
useShinyjs(),
## Window title
tags$head(
tags$link(rel = "icon", type = "image/png", sizes = "32x32", href = "myBrowserImage.png")),
# App title ----
titlePanel( title = div(img(src="myAppImage.png"), 'myAppTitle'), windowTitle = "myBrowserTitle" ),
# Rest of the UI
)
With the png images in a subfolder called "www".将 png 图像放在名为“www”的子文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.