I don't understand why my page loses all its design when I refresh it and it has a URL with an ID in vue-router

Whenever I try to redirect from the target component to the target-details component using a specific ID, I encounter an error when refreshing the page:

javascript Uncaught SyntaxError: Unexpected token '<'     app.js:1
. Additionally, after clicking the back button in the browser or redirecting to another page, the design corrects itself. I am puzzled by this behavior as all my other pages are functioning correctly.

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/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fa948a88959d889f8989bacad4c8d4ca">[email protected]</a>/nprogress.css" rel="stylesheet" />

    <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e08e90928f8792859393a0d0ced2ced0">[email protected]</a>/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"
            }
    },

Answer №1

Always be sure to use the complete path for your JavaScript and stylesheet files.

For example, include script like this:

<script type="text/javascript" src="/assets/js/script.js"></script>

Watch out for extra characters such as }} in your link tags for stylesheets like main-style.css.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error message in console: AngularJS throws an error saying 'No module found: uiCropper'

Hey there, I'm looking to add an image cropper to my webpage. I came across some code on Codepen, but when I tried using it, the code didn't work and I encountered this error https://i.sstatic.net/h5F4T.png angular.module('app', [&ap ...

Unable to stop React HTMLAudioElement from playing

In the realm of React, there exists a component that requires a URL input to function. The purpose of this component is to display a button that allows users to control the playback of an audio file. It's worth noting that this particular component is ...

What is the method for obtaining the div ID's from this form?

This is the scenario I am working on: my app takes the text inputted by the user and exports it to a specific website that contains similar elements. For example, if the user enters a title in the app and clicks a button, the app will transfer that value t ...

Is there a way to compress my JavaScript and CSS files using gzip?

I am facing an issue with gzipping a prototype library. I have no idea how to go about it, where to start, and how it actually works. I tried looking at some tutorials but unfortunately, they weren't very helpful... So here's the setup: I have ...

Issue encountered while attempting to start React and Node.js: NPM error

I've encountered some errors in my Node.js and React.js project. I have a server and a React SPA, both working independently. When I use "concurrently" to start them together, I get the following errors: [0] npm ERR! missing script: servernpm run clie ...

Currently, my goal is to create PDFs using Angular

<button class="print" (click)="generatePDF()">Generate PDF</button> Code to Generate PDF generatePDF(): void { const element = document.getElementById('mainPrint') as HTMLElement; const imgWidth = 210; ...

Implementing dynamic data binding in JavaScript templates

I've been experimenting with jQuery and templates, and I managed to create a basic template binding system: <script type="text/template" id="Template"> <div>{0}</div> </script> Furthermore... var buffer = ''; v ...

Navigating the page by utilizing Javascript through a CSS selector

I am encountering a small issue with scrolling a pop-up window. I am trying to scroll a popup that contains a div and some CSS code without using an ID or class. Here is the HTML CSS Code snippet: <div style="height: 356px; overflow: hidden auto;"> ...

If the div element with the ID "arrow" is present, assign the class "odd0" to its corresponding table row

    My current implementation involves assigning different colors to alternate table rows using the provided JavaScript: function alternate(id){         if(document.getElementsByTagName){            var table = document.getElementById(id);   ...

Tips for utilizing v-for in Vue.js to iterate through a JSON object and distribute the resulting elements into two separate div containers

One of my challenges involves using an Axios callback to receive a JSON array with 170 key:value pairs. I then utilize v-for to display each pair within its own div container nested in another div wrapper, resulting in a column layout. I aim to generate t ...

Invoke a JavaScript file within the MongoDB shell

Running a JS file directly from the Mongo shell using the query mongo localhost:27017/west createSumCollection.js has resulted in an error: "uncaught exception: SyntaxError: unexpected token: identifier : @(shell):1:6" The content of CreateSu ...

Set the background-color of each <td> element to be equal to a value in the array, with each group of three elements having the same

I am trying to color every <td> element in a row of three columns with the same color using the following code: for (var i = 0; itr < $("td").length; i++) { $("td").eq(i).css("background-color", Colors[i]); } However, this code colors each i ...

Tips for building a basic particle system with THREE.js

I am looking to create a simple particle system that forms a circle around the name of the site in the middle. The particles should move around in the circle, "die off," and then get recreated. While I am new to three.js, I have attempted to find a solut ...

Verify whether a component is a React.ReactElement<any> instance within a child mapping operation

I am facing a challenge with a component that loops through children and wraps them in a div. I want to exclude certain elements from this process, but I am struggling to determine if the child is a ReactElement or not (React.ReactChild can be a string or ...

What is the best way to use jQuery ajax to send various row identifiers when updating table data on another PHP page by selecting checkboxes?

When I select both of the green checkboxes, only the most recent table id is sent. The code below includes both the checkbox markup and jQuery function. Checkbox: <div class='md-checkbox has-success'> <input type='checkbox&apo ...

Click on the window.location.href to redirect with multiple input values

I am facing a challenge with my checkboxes (from the blog label) and the code I have been using to load selected labels. However, this code seems to only work for one label. Despite multiple attempts, I have found that it only functions properly with one ...

Calculating date discrepancies with JavaScript

Two fields are present, one for the start date and one for the end date. I would like to display the date difference in another text box when the user selects dates from a date picker. Although I have made some progress on this, I believe that there are st ...

Executing a sequence of jQuery's $.when().then() functions

I am facing challenges in understanding how to properly sequence my functions, especially in relation to the $.when() method. function y() { defer = $.Deferred(); $.when(defer).then(console.log(defer.state())); } y(); <script src="https://ajax.go ...

Discover the complete guide on incorporating a JavaScript library with additional dependencies in Angular 2

I am a beginner with angular 2 and I am attempting to integrate the Miso Dataset JavaScript library into my angular 2 project. The Miso library requires other JavaScript libraries as dependencies. Although I have included all the necessary JavaScript file ...

The issue of the cursor not showing up in Chrome within a nested contenteditable structure arises when applying CSS after the

Currently, I am coding a HTML document that includes an element with the attribute contenteditable set to true, but this element is wrapped inside a parent element with contenteditable set to false. The HTML structure looks like this: <div contentedita ...