[英]How to use CSS and JS resources in a routed page in Odoo?
I'm using Odoo controller to create a web page and make it public to customer so he doesn't need to login. 我正在使用Odoo控制器创建一个网页并将其公开给客户,因此他不需要登录。
In this page I'm trying to use CSS and JS libraries which exists in files inside the module (static folder). 在此页面中,我尝试使用模块和模块(静态文件夹)中存在的CSS和JS库。
The problem is that the page can't reach these resources because it searches for them in the domain of the URL not in the filesystem (ex. http://localhost:8069/mywebpage ) 问题在于该页面无法访问这些资源,因为它是在URL的域中而不是在文件系统中(例如http:// localhost:8069 / mywebpage )搜索这些资源。
I tried to inherit the template and the qweb design and inject the files but I got the same problem. 我试图继承模板和qweb设计并注入文件,但是遇到了同样的问题。
<template inherit_id="..."> <xpath expr="." position="inside"> <link rel="stylesheet" href="...">
The only solution I have found is copy/paste the source code of the JS libraries and CSS inside the template which is not a practical solution. 我发现的唯一解决方案是在模板内部复制/粘贴JS库和CSS的源代码,这不是一个实际的解决方案。
How can I make the routed page access the CSS and JS resources inside Odoo module? 如何使路由页面访问Odoo模块中的CSS和JS资源?
Just put the module path of your assets resources, like: 只需输入资产资源的模块路径即可,例如:
<link rel="stylesheet" href="/your_custom_module/static/src/css/file.css">
And be sure the file will be there, the same for js script definition. 并确保文件将在那里,与js脚本定义相同。
Also you should include in your posts the exact info and value that you are using, not ...
. 另外,您应该在帖子中包含您正在使用的确切信息和值,而不是
...
It doesn't help you into get a response using ...
, it just makes things difficult. 它不会帮助您使用
...
获得响应,只会使事情变得困难。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.