是否可以将 Webpack/VueJS 与 Odoo 框架(v12)集成? [英] Is it possible to integrate Webpack/VueJS with the Odoo Framework (v12)?

查看:307
本文介绍了是否可以将 Webpack/VueJS 与 Odoo 框架(v12)集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 WebPack 将 VueJS 集成到我的自定义 Odoo 模块之一中,并让它在我启动 Odoo-bin 时自动启动.

I'd like to integrate VueJS through WebPack in one of my custom Odoo modules, and have it start up automatically when I launch Odoo-bin.

有没有人有解决办法?甚至有可能吗?

Does anyone have a solution? Is it even possible?

我知道你可以将 VueJS 作为一个简单的 .JS 文件包含在模块的模板中,但这意味着我不能使用 WebPack 支持的 .vue 组件.

I know you can include VueJS as a simple .JS file in the module's template, but that means I can't use the .vue components supported by WebPack.

我还读到 Odoo 有自己的 JS 框架,但我找不到合适的教程/文档.

I also read that Odoo has its own JS framework, but I couldn't find good tutorials/documentation for it.

对于任何可能想知道我是如何解决这个问题的人来说,这是我所做的:

我使用 npm init 在我的 Odoo 文件夹的根目录中初始化了一个 package.json 文件.我向包中添加了一个启动脚本,用于启动 webpack 并将所有 vue 组件捆绑在 myAddons 文件夹(我存储自定义模块的位置)中,然后通过 python odoo-bin ... 命令启动 Odoo.剩下的就是使用 npm start 来启动它.

I initialized a package.json file in the root of my Odoo folder using npm init. I added a start script to the package that launches webpack and bundles all vue components in myAddons folder (where I store my custom modules), then launches Odoo through the python odoo-bin ... command. All that's left is to use npm start to start it all up.

通过这种方式,vue 组件被捆绑到单个 JS 文件中,然后我将其添加到我的模块的模板中.这有一个小不便,因为必须手动完成第一个包才能知道需要将哪些 JS 文件导入到模板中.此外,我仍在尝试弄清楚如何分别捆绑每个模块的组件.一旦我找到合适的方法,就会更新这个....希望如此.

This way, the vue components get bundled into single JS files, that I then add to the templates of my modules. This has a small inconvenient in that the first bundle has to be done manually in order to know which JS files need to be imported to the templates. Also, i'm still trying to figure out how to bundle the components of every single module separately. Will update this once I find a proper way to do it. ...Hopefully.

推荐答案

默认情况下,odoo 前端部分主要基于 backbone、jquery、underscore.如果你想使用任何其他 JS 库,你必须确保它们之间的兼容性.odoo 后端部分的 JS 功能写在 web 模块下,可以在 odoo 社区代码的 odoo/addons/web/static/src/js 目录中找到.电子商务/网站部分位于 website* 模块下.

By default, odoo frontend part is heavily built upon backbone, jquery, underscore. If you want to use any other JS library, you have to make sure the compatibility in between them. The odoo backend parts of JS functionalities are written under web module can be found in odoo/addons/web/static/src/js directory in odoo community codes. The ecommerce/website part is under website* modules.

这篇关于是否可以将 Webpack/VueJS 与 Odoo 框架(v12)集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆