我正在尝试访问我的css和js文件(位于resources / css / stylesheet.css和../js/ ..),但是我不确定如何访问。
我已经尝试在和标记之间使用$ webResourceManager.requireResource(xxx:xxx),但它只是在网页上打印$ webRes...。我还使用了#requireResource(xxx:xxx)的头部。它没有将其打印在页面上,但也不起作用。
在 atlassian-plugin.xml
<web-resource key="statPlugin-resources" name="statPlugin Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="statPlugin.css" location="/css/statPlugin.css"/>
<resource type="download" name="statPlugin.js" location="/js/statPlugin.js"/>
<resource type="download" name="images/" location="/images"/>
<resource type="velocity" name="test" location="/templates/test.vm"/>
<context>statPlugin</context>
</web-resource>
在page.vm
<head>
<title>Stat Plugin Configuration</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
$webResourceManager.requireResource("com.tdk.plugin:statPlugin-resources")
<body>
...
</body>
错误消息:未捕获ReferenceError:未定义addCard 在HTMLButtonElement.onclick(stat-config:33)
因此找不到js文件。
答案 0 :(得分:0)
答案很简单,但是由于文档过时,很难找到答案。在第一次尝试中,我尝试使用不再被弃用的WebresourceManager。您必须使用ConfluenceWebresourceManager
。使用组件导入时,您可以访问它。
要为Velocity插件提供必须使用的资源管理器
context.put("confluenceWebResourceManager",confluenceWebresourceManager");
在servlet的doGet或doPost中。
您必须在模板本身中写以下内容:
<head>
...
</head>
$confluenceWebResourceManager.requireResource("com.company.plugin.pluginName:pluginName-resources")
<body>
...