我正在尝试创建一个简单的小部件 Backbase,但是,它向我显示了一个错误 ReferenceError: requireWidget is not defined。我认为它与 RequireJS 相关,但他的钩子本身并没有做任何事情。也许有人知道如何处理它?
index.html 文件:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:g="http://www.backbase.com/2008/gadget" xml:lang="en">
<head>
<title>Todo Widget</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<g:preferences>
<g:preference name="limit" label="Todo's Limit" type="text" default="5" viewHint="none" />
</g:preferences>
</head>
<body g:onload="requireWidget(__WIDGET__, 'todo')" class="todo-widget">
<h1>Todo Widget</h1>
</body>
</html>
和js文件
define(["jquery"], function($) {
"use strict";
var self;
function Todo(widget) {
self = this;
self.widget = widget;
self.$widget = $(widget.body);
return self;
}
Todo.prototype.init = function() {
window.alert('it works!');
}
return function(widget) {
var todo = new Todo(widget);
todo.init();
}
});