sunmao-ui/packages/runtime/example/router/hashNested.html
2021-08-31 11:18:11 +08:00

250 lines
6.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>meta-ui runtime example: nested hash router</title>
<script>
delete window.history;
</script>
</head>
<body>
<div id="root"></div>
<script type="module">
import renderApp from '../../src/main.tsx';
renderApp({
version: 'example/v1',
metadata: {
name: 'nested_hash_router',
description: 'nested hash router example',
},
spec: {
components: [
{
id: 'parent',
type: 'core/v1/router',
properties: {
switchPolicy: [
{
type: 'route',
path: '/1',
slotId: 'child1',
default: true,
},
{
type: 'route',
path: '/2',
slotId: 'child2',
default: false,
},
],
},
traits: [],
},
{
id: 'child1',
type: 'core/v1/router',
properties: {
switchPolicy: [
{
type: 'route',
path: '/1',
slotId: 'grandchild1_1',
default: true,
},
{
type: 'route',
path: '/2',
slotId: 'grandchild1_2',
default: false,
},
{
type: 'route',
path: '/3',
slotId: 'grandchild1_3',
default: false,
},
],
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'parent',
slot: 'child1',
},
},
},
],
},
{
id: 'child2',
type: 'core/v1/router',
properties: {
switchPolicy: [
{
type: 'route',
path: '/1',
slotId: 'grandchild2_1',
default: true,
},
{
type: 'route',
path: '/2',
slotId: 'grandchild2_2',
default: false,
},
{
type: 'route',
path: '/3',
slotId: 'grandchild2_3',
default: false,
},
],
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'parent',
slot: 'child2',
},
},
},
],
},
{
id: 'grandchild1_1',
type: 'core/v1/text',
properties: {
value: {
raw: '1_1',
format: 'plain',
},
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'child1',
slot: 'grandchild1_1',
},
},
},
],
},
{
id: 'grandchild1_2',
type: 'core/v1/text',
properties: {
value: {
raw: '1_2',
format: 'plain',
},
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'child1',
slot: 'grandchild1_2',
},
},
},
],
},
{
id: 'grandchild1_3',
type: 'core/v1/text',
properties: {
value: {
raw: '1_3',
format: 'plain',
},
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'child1',
slot: 'grandchild1_3',
},
},
},
],
},
{
id: 'grandchild2_1',
type: 'core/v1/text',
properties: {
value: {
raw: '2_1',
format: 'plain',
},
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'child2',
slot: 'grandchild2_1',
},
},
},
],
},
{
id: 'grandchild2_2',
type: 'core/v1/text',
properties: {
value: {
raw: '2_2',
format: 'plain',
},
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'child2',
slot: 'grandchild2_2',
},
},
},
],
},
{
id: 'grandchild2_3',
type: 'core/v1/text',
properties: {
value: {
raw: '2_3',
format: 'plain',
},
},
traits: [
{
type: 'core/v1/slot',
properties: {
container: {
id: 'child2',
slot: 'grandchild2_3',
},
},
},
],
},
],
},
});
</script>
</body>
</html>