Skip to content

Commit

Permalink
fix: allow to turn off prefetching globally
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Apr 8, 2019
1 parent e39e99b commit 28a2d19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ new VueRouter({
})
```

It's also possible to turn of prefetching globally:

```js
Vue.use(RouterPrefetch, {
prefetch: false
})
```

### prefetchFiles

- Type: `string[]`
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import prefetch from './prefetch'
import { canPrefetch, supportIntersectionObserver, inBrowser } from './utils'

function installRouterPrefetch(Vue, { componentName = 'RouterLink' } = {}) {
function installRouterPrefetch(
Vue,
{ componentName = 'RouterLink', prefetch: enablePrefetch = true } = {}
) {
const observer =
supportIntersectionObserver &&
new window.IntersectionObserver(entries => {
Expand Down Expand Up @@ -40,7 +43,7 @@ function installRouterPrefetch(Vue, { componentName = 'RouterLink' } = {}) {
props: {
prefetch: {
type: Boolean,
default: true
default: enablePrefetch
},
prefetchFiles: {
type: Array
Expand Down

0 comments on commit 28a2d19

Please sign in to comment.