Vue component encountering an invalid closing tag despite having a balance of all tags

I am facing an unusual issue with my Vue component. It seems that the component is not rendering properly (the output is <!---->), and my IDE is indicating an invalid end of the component, even though the tags are correctly balanced.

Here is the code for the entire component, which is quite straightforward:

<template>    
    <div class="card activity">
        <div class="card-body">
            <div class="row">
            <template v-if="activity.icon">
                <div class="col-md-4">
                    <div class="icon">
                        <template v-if="activity.icon_type == 'font-awesome'">
                            <i :class="activity.icon"></i>
                        </template>
                    </div>
                </div>            
            </template>
            
            <template v-if="activity.icon">
                <div class="col-md-8">
            </template>
            <template v-else>
                <div class="col">
            </template>
            
                    <h2 v-html="activity.title"></h2>

                    <template v-if="activity.description">
                        <p v-html="activity.description"></p>
                    </template>

                    <template v-if="activity.link">
                        <a :href="activity.link" class="btn btn-primary">{{ activity.link_text ? activity.link_text : 'Read More' }}</a>
                    </template>
                </div>
            </div>
        </div>
    </div>    
</template>

<script>
    export default {
        props: {
            activity: {
                type: Object,
                required: true
            },
        },

        data() {
            return {};
        },

        mounted() {
            console.log(this.activity);
        },

        computed: {
        },

        methods: {
        }
    }
</script>

The error reported by my IDE (VS Code) is:

[vue/no-parsing-error]
Parsing error: x-invalid-end-tag.eslint-plugin-vue

Upon investigation, I found that the issue lies in these lines of code:

<template v-if="activity.icon">
    <div class="col-md-8">
</template>
<template v-else>
    <div class="col">
</template>

Removing this block resolves the problem. What could be causing this discrepancy?

Answer №1

Your approach is clear, but consider using this replacement for the div element instead

<div :class="activity.icon ? 'col-md-8' : 'col'">

Answer №2

Make sure to properly format the div tags:

    <template v-if="activity.icon">
        <div class="col-md-8"></div>
    </template>
    <template v-else>
        <div class="col"></div>
    </template>

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

Javascript code fails to execute properly on IE8

I have a scenario where I am working with two drop-down menus. When the user selects an option from one menu, it should dynamically change the options in the other menu. However, I'm facing an issue with Internet Explorer where the second drop-down me ...

the ajax post method

I recently wrote some code that involves two files (index.html and jeu.php). In the index.html file, when I submit a form, I am supposed to be redirected to the other page (jeu.php). However, the issue seems to be with the click event. <html> <he ...

Connecting via web sockets through SSL is not functioning properly

My Web Socket functions correctly in both the localhost and production environments (https://www.example.com). However, upon deploying the same code to the pp environment (), I encounter the error message: WebSocket handshake - Unexpected response code: 4 ...

When utilizing json.loads in Python 2.7, it yields a unicode object rather than a dictionary

I'm currently facing a challenge with converting JSON data into a dictionary, and I'm struggling to find a solution. My situation involves connecting to a Tornado websocket from JavaScript and sending the following data inputted into a textfield ...

Establishing the preset values for Material-UI toggle button group

I utilized the Material UI library to implement a button toggle widget for selecting options. Check out my codesandbox project here - https://codesandbox.io/s/50pl0jy3xk The user can interact by choosing a membership type: adult, child, or infant. Option ...

Once chosen, zoom in on the map to view the results

I am facing an issue with multiple selects in my code, where one select depends on the result of another. The ultimate goal is to zoom in on the area that has been searched and found, but unfortunately, it is not functioning as expected. If you'd lik ...

Is there a way to transfer a set of data into another collection within Angularfire, Angular, or Firestore and designate it as a sub

I currently manage two unique collections: Collection 1 consists of various modules, While Collection 2 includes profiles nested within modules as a sub-collection. My goal is to transfer all documents from Collection 1 to Collection 2 in a one-time ope ...

The server is failing to send the Set-Cookie header

Currently focusing on learning about handling cookies with node.js and express, I encountered a peculiar issue. Inside my cookie.js file, the code structure is as follows: var router = require('express').Router(); router.get('/cookie/&apos ...

Creating an executable JAR for your Next.js application: A step-by-step guide

Is there a way to ensure that my Next.js file can run seamlessly on any computer without the need for reinstallation of all modules? In my folder, nextjs-node, I have the following subfolders: components lib public node_modules page style package.json I ...

I discovered an issue in Handsontable while trying to copy and paste a numeric value in German format

For my upcoming project, I am looking to incorporate the Handsontable JavaScript grid framework. However, I have encountered a small bug that is hindering me from utilizing this library to its fullest potential. The task at hand involves displaying a tabl ...

The if statement remains active without being disabled

Currently, I am working on coding a bot for my school that includes a feature allowing students to talk in a voice channel if they send a specific message and the teacher reacts with a specific emoji. Below is the code snippet: client.on('message&apos ...

Developers guide to using Selenium IDE

After downloading the source code of Selenium IDE, I'm eager to make some edits but unfortunately, I can't seem to find any documentation on how to do so. Hey folks, anyone aware of any resources available for developers working on Selenium IDE? ...

How to dynamically add variables to object paths using JavaScript and Angular

I've been struggling to grasp this concept, despite hours of searching. My goal is to dynamically generate form fields based on a user-selected 'type' from a dropdown menu. This will be linked to the variable "currentType" in Angular, which ...

"Calling getElementByID results in a null value being returned (see example in the provided

In my attempt to design unique buttons for a media player, I encountered a challenge. I envisioned the play button transitioning into a "loading" button and eventually into a pause button. My solution involved using 4 div elements - stop, play, loading, a ...

Facing issues with integrating Laravel and VueJS within a Laravel application

Interested in Laravel 5.7 and Vue Js, here is a snippet from app.js let Myheader = require('./components/Myheader.vue'); let Myfooter = require('./components/Myfooter.vue'); const app = new Vue({ el: '#app', componen ...

Finding unique values by mapping and returning them without any duplicates

Currently, I'm working on a mapping task and facing an issue. In my code snippet, I attempted to eliminate duplicate values by using <h3 key={i}>{_.uniq(person.name)}</h3> from lodash library. However, the output still displays duplicate v ...

Utilizing the variable's value as a parameter in a jQuery selector

I am having trouble replacing $('#divy a:lt(3)') with the variable instead of a hard-coded number like $('#divy a:lt(count)'). Check out this Fiddle for more information. var timerId, count = 0; function end_counter() { $('# ...

Tips on successfully passing multiple keys and their associated HTML tag attributes in a React application

One of my links, specified with an a-tag, appears in this manner: <a href={ item.htmlReportUrl } target="_blank" rel="noopener noreferrer"> {item.htmlReportText}</a> The values for the href and the linktext are sourced from the following: ro ...

Angular tutorial: Accessing individual HTML elements within the *ngFor loop

I am facing an issue trying to access the "box-message" class using "document.querySelectorAll('.box-message')" within a tree structure where the "*ngFor" directive is utilized. After making an "http rest" request, the *ngFor directive finishes ...

Is there a method to retrieve a value from a node.js server when a div is clicked?

This is the EJS file I've created: <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Sart Plug</title> <script src="http://code.jquer ...