/** * {wkitd} * @author yutent * @date 2023/08/10 10:02:15 */ import './init.js' import { html, css, Component } from 'wkit' import { noop } from './utils.js' export * from './router/index.js' export { createStore } from './store.js' class App extends Component {} export function createApp({ data = {}, methods = {}, mounted = noop, render } = {}) { // return new (function () { App.props = data Object.assign(App.prototype, methods, { mounted }) this.use = function (plugin = noop, ...args) { plugin.apply(this, args) return this } this.mount = function () { let $router = window.__wkitd__.get('$router') if (render) { App.prototype.render = render } else { if ($router) { App.prototype.render = function () { return html`` } } else { App.styles = css` :host { font-family: monospace; color: #647889; } .code { margin: 16px 0; background: #f7f8fb; } ` App.prototype.render = function () { return html`

It works!!!

If you don't use router, you may define the render property.
  createApp({
    render() {
      return html\`<wc-home></wc-home>\`
    }
  })
  .mount()
` } } } if ($router) { App.prototype.mounted = function (...args) { let $view = window.__wkitd__.get('ROUTER_VIEW') $view.sync($router.getViews()) $router.init() mounted.call(this, ...args) } } App.reg('app') } })() }