我使用Laravel7,vue @ 2.6.11,@ vue / cli 4.1.1
在此配置中,发生以下情况: 当我单击“公式”路线时,将发生过渡并呈现页面。
如果刷新页面,则该页面不会呈现组件“公式”的内容。
登录后如何呈现页面 进入公式页面上的网站?
app.js
import App from './components/App.vue';
import Vue from 'vue';
import router from './router'
export default new Vue({
router,
render: h => h(App)
});
App.Vue
<template>
<div id="app">
<router-view></router-view>
<router-link :to="{ name: 'Formula' }">Formula</router-link>
</div>
</template>
<script>
export default{
data() {
return {
app_id: null,
}
},
}
</script>
router.js
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router);
import Formula from './components/formula/formula'
export default new Router({
mode: 'history',
routes: [
{path: '/formula', component: Formula, name: 'Formula'},
]
});
entry-server.js
import app from './app'
import router from './router';
new Promise((resolve, reject) => {
router.push(url);
router.onReady(() => {
const matchedComponents = router.getMatchedComponents();
if (!matchedComponents.length) {
return reject({ code: 404 });
}
resolve(app);
}, reject);
})
.then(app => {
renderVueComponentToString(app, (err, res) => {
print(res);
});
})
.catch((err) => {
print(err);
});
entry-client.js
import app from './app'
app.$mount('#app');
app.blade.php (index.html)
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<body>
{!! $ssr !!}
<script src="{{ asset('js/entry-client.js') }}" type="text/javascript"></script>
</body>
</html>
为什么会这样? 我该如何解决?