vue-router为什么当我刷新一个包含ID的URL的页面时,我会丢失所有页面的设计

问题描述 投票:0回答:1

我是使用特定ID从目标组件到目标详细信息组件的重定向,所以我的问题是,刷新页面时出现错误javascript Uncaught SyntaxError: Unexpected token '<' app.js:1。然后单击浏览器的后退按钮或重定向到另一个页面,然后再次返回设计我不知道发生了什么,其他所有页面也都正常工作。

index.html

<head>
    <meta name="author" content="Nile-Theme">
    <meta name="robots" content="index follow">
    <meta name="googlebot" content="index follow">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- google fonts -->
    <link href="https://fonts.googleapis.com/css?family=Poppins:100,200,300,400,500,600,700|Tajawal:400,500,600,700&display=swap" rel="stylesheet">

    <link rel="stylesheet" href="./build/css/flaticon.css">
    <link rel="stylesheet" href="./build/css/all.css">
    <link rel="stylesheet" href="./build/css/app.css">
    <link rel="stylesheet" href="./build/css/style.css">

    <!-- main dashboard -->
    <link rel="stylesheet" href="./build/css/now-ui-dashboard.css') }}">

    <!-- Nprogress -->
    <link href="https://unpkg.com/[email protected]/nprogress.css" rel="stylesheet" />

    <script src="https://unpkg.com/[email protected]/nprogress.js"></script>



</head>

<body >
    <noscript>
      <strong>We're sorry but full-hunt doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->

    <!-- js file -->
    <script type="text/JavaScript" src="./build/js/app.js"></script>

</body>

target.js

<template>
   <div class="page-output">
        <div class="container">

           <h1>Target page</h1>
 <li class="clearfix" v-for="domain in domains" :key="domain.domain_id">{{ domain.domain }} 
                            <router-link class="more" 
                                :to="{ 
                                        name: 'target-details', 
                                        params: { 
                                            id: domain.domain_id 
                                        } 
                                    }" >Target details <i class="fa fa-angle-right"></i>
                            </router-link>
                        </li>
        </div>
    </div>
</template>

target-details.js

<template>
    <div>
        <div class="page-output">
            <div class="container">
              <div class="target-title">
                    <router-link class="right" to="/targets"><i class="fa fa-angle-left"></i> {{ geNameDomainById(id) }} domain</router-link>
                    <a href="#" class="left"><i class="fa fa-cog"></i> Domain settings</a>
                </div>
           </div> 
        </div>
</template>

router.js

 {
        path: '/targets',
        name: 'target',
        component: () =>
            import ( /* webpackChunkName: "target" */ '@/views/admin/Target.vue'),
            meta: {
                middleware: [
                    auth
                ],
                title: "Targets"
            },
    },
    {
        path: '/targets/:id/details',
        name: 'target-details',
        component: () =>
            import ( /* webpackChunkName: "target" */ '@/views/admin/TargetDetails.vue'),
            meta: {
                middleware: [
                    auth
                ],
                title: "TargetDetails"
            }
    },
javascript vue.js single-page-application vuex vue-router
1个回答
2
投票
例如<script type="text/javascript" src="/build/js/app.js"></script>
© www.soinside.com 2019 - 2024. All rights reserved.