-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Require Vue 3 and Vue Router 4
- Loading branch information
1 parent
c62f9a0
commit a9c916b
Showing
12 changed files
with
985 additions
and
3,140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
dist | ||
cypress/videos | ||
cypress/screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="./index.jsx"></script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { createApp, h } from 'vue' | ||
import { createRouter, createWebHashHistory, RouterView } from 'vue-router' | ||
import RoutePrefetch from '../src' | ||
import Nav from './nav.vue' | ||
|
||
const app = createApp({ | ||
setup() { | ||
return () => h(RouterView) | ||
} | ||
}) | ||
|
||
const router = createRouter({ | ||
history: createWebHashHistory(), | ||
routes: [ | ||
{ | ||
path: '/', | ||
component: { | ||
render() { | ||
return ( | ||
<div> | ||
<h1>hi</h1> | ||
<Nav /> | ||
</div> | ||
) | ||
} | ||
} | ||
}, | ||
{ | ||
path: '/async-page', | ||
meta: { | ||
prefetch(route) { | ||
console.log(route) | ||
} | ||
}, | ||
component: () => import('./async-page.vue') | ||
} | ||
] | ||
}) | ||
|
||
app.use(router) | ||
app.use(RoutePrefetch) | ||
|
||
window.pages = new Set() | ||
|
||
const createPage = id => async () => { | ||
console.log(`fetching page ${id}`) | ||
window.pages.add(id) | ||
return { | ||
render() { | ||
return ( | ||
<div> | ||
<h1>page {id}</h1> | ||
<Nav /> | ||
</div> | ||
) | ||
} | ||
} | ||
} | ||
|
||
for (let i = 0; i < 6; i++) { | ||
router.addRoute({ | ||
path: `/page/${i + 1}`, | ||
component: createPage(i + 1) | ||
}) | ||
} | ||
|
||
app.mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<template> | ||
<div> | ||
<ul> | ||
<li> | ||
<router-link to="/page/1">page 1</router-link> | ||
</li> | ||
<li> | ||
<router-link to="/page/2">page 2</router-link> | ||
</li> | ||
<li> | ||
<router-link to="/page/3">page 3</router-link> | ||
</li> | ||
</ul> | ||
<ul style="margin-top: 110vh;" id="bottom"> | ||
<li> | ||
<router-link to="/page/4" :prefetchFiles="['/foo']"> | ||
page 4 | ||
</router-link> | ||
</li> | ||
<li> | ||
<router-link to="/page/5">page 5</router-link> | ||
</li> | ||
<li> | ||
<router-link to="/async-page">async-page</router-link> | ||
</li> | ||
<li> | ||
<router-link to="/page/6">page 6</router-link> | ||
</li> | ||
<li> | ||
<router-link to="/page/1">page 1</router-link> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import vue from '@vitejs/plugin-vue' | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
plugins: [vue()], | ||
esbuild: { | ||
jsxFactory: 'h' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.