我正在尝试根据文档执行一小段javascript代码,但无法正常工作
__ manifiedt __。py
'depends': ['base','website'],
# always loaded
'data': [
'security/ir.model.access.csv',
'views/views.xml',
'views/templates.xml',
],
constroller.py
@http.route('/web_java_11/', auth='public',website=True)
def list(self, **kw):
return http.request.render('web_java_11.index_2', {})
template.xml
<template id="ticket_assets" name="Ticket Viewer Application Assets" inherit_id="web.assets_frontend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/bus/static/src/js/bus.js"/>
<script src="/web_java_11/static/src/js/js_pg.js"></script>
</xpath>
</template>
<template id="index_2" name="acp_index_2">
<t t-call="web.layout">
<t t-set="head">
<t t-call-assets="web.assets_common" t-js="false"/>
<t t-call-assets="web.assets_common" t-css="false"/>
<t t-call-assets="web.assets_backend" t-css="false" />
<t t-call-assets="web.assets_frontend" t-css="false" />
</t>
<div class="oe_application">hello app</div>
</t>
</template>
js.pg.js
odoo.define('demo.views', function (require) {
"use strict";
var core = require('web.core');
var Widget = require('web.Widget');
var bus = require('bus.bus').bus;
var qweb = core.qweb;
var _t = core._t;
require('web.dom_ready');
var acp_barcode = Widget.extend({
template: "webjava_barcode",
start: function(){
console.log('ok');
},
});
var $elem = $('.oe_application');
var app = new acp_barcode(null);
app.appentTo($elem).then(function(){
console.log('end');
bus.start_polling();
});
});
错误
一切正常,但是在加载页面时抛出错误,因此我看不到demo.views
答案 0 :(得分:0)
我做了一些修改,现在可以了
__ manifiedt __。xml
public class Animal
{
private String id;
private String species;
private String name;
public Animal(String species, String name, MyZoo owner)
{
id = owner.allocateId();
this.species = species;
this.name = name;
}
public String getId()
{
return id;
}
public String getName()
{
return name;
}
public String getSpecies()
{
return species;
}
public String toString()
{
return id + " " + name + ": a " + species;
}
}
js_pg.js
重命名功能
'qweb': ['static/src/xml/acp.xml'],
在初始化方法中调用方法_super
odoo.define('web_java_11.app',...
在类acp_application中应用了模板
require('web.dom_ready');
var App = Widget.extend({
template: "showData",
init: function(parent) {
console.log('init');
this._super.apply(this, arguments);
},
start: function(){
console.log('entra');
},
});
template.xml
var $elem = $('.acp_application');
var app = new App();
app.appendTo($elem).then(function () {
bus.start_polling();
});
acp.xml
<template id="index_2" name="acp_index_2">
<html>
<head>
<t t-call-assets="web.assets_common" />
<t t-call-assets="web.assets_backend" />
<t t-call-assets="web.assets_frontend" />
</head>
<body>
<div class="container">
<div class="acp_application"></div>
</div>
</body>
</html>
</template>