fix demo code

This commit is contained in:
Géry Debongnie
2019-01-20 09:35:39 +01:00
parent 041830c684
commit d0bdf0ed8b
2 changed files with 18 additions and 17 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ export default class Counter extends Widget {
counter: 0 counter: 0
}; };
constructor(parent: Widget, props: {initialState?: number}) { constructor(parent: Widget | null, props: {initialState?: number}) {
super(parent); super(parent);
this.state.counter = props.initialState || 0; this.state.counter = props.initialState || 0;
} }
+17 -16
View File
@@ -1,22 +1,23 @@
///<amd-module name="main" /> ///<amd-module name="main" />
import QWeb from "../../src/core/qweb_vdom"; // import QWeb from "../../src/core/qweb_vdom";
import {init} from "../../src/libs/snabbdom/src/snabbdom" // import {init} from "../../src/libs/snabbdom/src/snabbdom"
import h from "../../src/libs/snabbdom/src/h" // import h from "../../src/libs/snabbdom/src/h"
import sdProps from "../../src/libs/snabbdom/src/modules/props" // import sdProps from "../../src/libs/snabbdom/src/modules/props"
import sdListeners from "../../src/libs/snabbdom/src/modules/eventlisteners" // import sdListeners from "../../src/libs/snabbdom/src/modules/eventlisteners"
const patch = init([sdProps, sdListeners]); // const patch = init([sdProps, sdListeners]);
(<any>window).h = h; // (<any>window).h = h;
(<any>window).patch = patch; // (<any>window).patch = patch;
(<any>window).QWeb = QWeb; // (<any>window).QWeb = QWeb;
import Counter from "./Counter";
// import RootWidget from "./RootWidget"; // import RootWidget from "./RootWidget";
// import env from "./env"; import env from "./env";
// document.addEventListener("DOMContentLoaded", async function() { document.addEventListener("DOMContentLoaded", async function() {
// const rootWidget = new RootWidget(null); const rootWidget = new Counter(null, {});
// rootWidget.setEnvironment(env); rootWidget.setEnvironment(env);
// const mainDiv = document.getElementById("app")!; const mainDiv = document.getElementById("app")!;
// await rootWidget.mount(mainDiv); await rootWidget.mount(mainDiv);
// }); });