Skip to content

Commit 28a2d19

Browse files
committed
fix: allow to turn off prefetching globally
1 parent e39e99b commit 28a2d19

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ new VueRouter({
7373
})
7474
```
7575

76+
It's also possible to turn of prefetching globally:
77+
78+
```js
79+
Vue.use(RouterPrefetch, {
80+
prefetch: false
81+
})
82+
```
83+
7684
### prefetchFiles
7785

7886
- Type: `string[]`

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import prefetch from './prefetch'
22
import { canPrefetch, supportIntersectionObserver, inBrowser } from './utils'
33

4-
function installRouterPrefetch(Vue, { componentName = 'RouterLink' } = {}) {
4+
function installRouterPrefetch(
5+
Vue,
6+
{ componentName = 'RouterLink', prefetch: enablePrefetch = true } = {}
7+
) {
58
const observer =
69
supportIntersectionObserver &&
710
new window.IntersectionObserver(entries => {
@@ -40,7 +43,7 @@ function installRouterPrefetch(Vue, { componentName = 'RouterLink' } = {}) {
4043
props: {
4144
prefetch: {
4245
type: Boolean,
43-
default: true
46+
default: enablePrefetch
4447
},
4548
prefetchFiles: {
4649
type: Array

0 commit comments

Comments
 (0)