简体   繁体   English

如何在Odoo的路由页面中使用CSS和JS资源?

[英]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.

相关问题 当前歌曲在 React JS 中路由到另一个页面时暂停,如何保持播放? - current song getting paused when routed to another page in react JS, how to keep it playing? 从假/本地路径加载页面资源(.css,.js) - Load Page resources (.css, .js) from fake/local path 每次页面被路由到时如何使用 res.render 发送数据? - How to use res.render to send data every time a page is routed to? 如何使用js或jquery在一个页面中使用多个css切换开关 - How to use multiple css toggle switches in one page with js or jquery 如何使用 react js 为不同的页面使用不同的 CSS 文件 - How to use different CSS files for different page with react js 如何使用带有 react.js webapp 的 Bootstrap html/css 页面? - How to use a Bootstrap html/css page with a react.js webapp? 在 Next JS 中导航到动态路由页面返回错误 - Navigating to dynamically routed page in Next JS returns error Owl.carousel.min.js 在 Angular 上重新加载路由页面 - Owl.carousel.min.js Routed Page Reload on Angular 如何将放置在war中的UI资源(如CSS,Images和Js文件)用作放置在单独war中的源jsp文件? - How to use UI resources like CSS, Images and Js files which are placed inside a war into the source jsp files that are placed in a separate war? 如何查找Chrome中阻止的资源(CSS,JS Etc) - How to find resources(CSS , JS Etc) that are blocking in Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM