add day 6
This commit is contained in:
25
day6/src/main.ts
Normal file
25
day6/src/main.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Reactive } from './lib/ReactiveObject'
|
||||
import { loadPage, hydratePage } from './lib/router';
|
||||
import { getCookie } from './lib/cookieManager';
|
||||
import '/src/style.css';
|
||||
|
||||
export const appState = new Reactive({
|
||||
count: 0,
|
||||
cookie: getCookie('username'),
|
||||
text: '',
|
||||
year: '',
|
||||
cookiedata: ""
|
||||
});
|
||||
|
||||
// equivalent to mounted() on svelte or vue
|
||||
window.addEventListener('load', async () => {
|
||||
// loadPage after all the index is loaded
|
||||
if (!import.meta.env.SSR) {
|
||||
await loadPage()
|
||||
} else {
|
||||
await hydratePage()
|
||||
}
|
||||
window.onpopstate = async () => {
|
||||
await loadPage()
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user