Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图在我的页面头部获取一个页面属性,以使其普遍可用,以便前端开发人员可以在他们的脚本中随意使用它。
这是在 AEM 6.3 上。而且我已经尝试在 head.html 中包含一个脚本,但它无法读取脚本标记中的页面属性。
<script> window.myAppEndpoint = { baseURL: "${properties.myappendpoint}" }; </script>
我希望用我的端点值填充的窗口对象能够在应用程序的任何地方使用它。
您可以在 js 中创建一个全局对象,并将该 js 包含在模板级别的 clientlib 中。或者使用 HTL 中可用的全局对象。请看这里。
您应该能够做到这一点,前提是:
myappendpoint
jcr:content
baseURL: "${properties.myappendpoint @ context='uri'}"