How to use the kpc/components/app function in kpc

To help you get started, we’ve selected a few kpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ksc-fe / kpc / components / app / demos / basic / index.js View on Github external
_mount() {
        // 通过container来指明挂载点
        this.app = new App({container: this.refs.container});
    }
github ksc-fe / kpc / site / src / client.js View on Github external
import 'core-js/es6/promise';
import './main';
import router from './router';
import createHistory from 'history/createBrowserHistory';
import App from 'kpc/components/app';
import Link from 'kpc/components/link';
import serverStyleCleanup from 'node-style-loader/clientCleanup';

const history = createHistory();
const $app = new App({container: document.getElementById('page'), ssr: true});

$app.history = history;
Link.history = history;
window.$app = $app;

let unlisten;
function init(router) {
    if (unlisten) unlisten();

    unlisten = history.listen(async ({pathname}, action) => {
        $app.showLoading();
        const {Page, data} = await router.resolve({pathname});
        await $app.load(Page, data, serverStyleCleanup);
    });
    history.replace(location);
}
github ksc-fe / kpc / site / src / render.js View on Github external
return router.resolve({pathname: path}).then(({Page, data}) => {
        const $app = new App();
        return $app.render(Page, data).then(() => {
            return {
                content: $app.toString(),
                style: collectInitial(),
            };
        }).catch(e => {
            console.log(e.stack);
        });
    });
}