mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix: Don't call fixPrepatch on non-dynamic routes
This commit is contained in:
parent
6f6a184f92
commit
39ef28ca2a
@ -389,6 +389,7 @@ function fixPrepatch(to, ___) {
|
||||
|
||||
instances.forEach((instance, i) => {
|
||||
if (!instance) return
|
||||
if (to.matched[i].path.indexOf(':') === -1) return // If not a dyanmic route, skip
|
||||
if (instance.constructor._dataRefresh && _lastPaths[i] === instance.constructor._path && typeof instance.constructor.options.data === 'function') {
|
||||
const newData = instance.constructor.options.data.call(instance)
|
||||
for (let key in newData) {
|
||||
|
20
test/fixtures/spa/pages/mounted.vue
vendored
Normal file
20
test/fixtures/spa/pages/mounted.vue
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<h1>Test: {{ test.text }}</h1>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
test: {
|
||||
text: null
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.test = {
|
||||
text: 'updated'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -66,6 +66,12 @@ test.serial('/custom (call mounted and created once)', async t => {
|
||||
t.true(logSpy.withArgs('mounted').calledOnce)
|
||||
})
|
||||
|
||||
test.serial('/mounted', async t => {
|
||||
const { html } = await renderRoute('/mounted')
|
||||
|
||||
t.true(html.includes('<h1>Test: updated</h1>'))
|
||||
})
|
||||
|
||||
test('/_nuxt/ (access publicPath in spa mode)', async t => {
|
||||
const { response: { statusCode, statusMessage } } = await t.throws(renderRoute('/_nuxt/'))
|
||||
t.is(statusCode, 404)
|
||||
|
Loading…
Reference in New Issue
Block a user