In Vue templates, any spaces or line breaks between element tags are not disregarded

<template>
    <div>
        <p>
            hello universe
        </p>
    </div>
</template>

Result:

<p> hello universe </p>

We need to get rid of the unnecessary spaces before and after "hello universe". How can we achieve this using webpack or linting?

vue.config.js

chainWebpack: (config) => {
        config.module
            .rule('vue')
            .use('vue-loader')
            .tap(options => {
                options.compilerOptions.whitespace = "condense"
                merge(options, {
                    optimizeSSR: false
                })
            }); 
...

Answer №1

The problem may be related to the whitespace: condense setting you are using in your Vue configuration.

As stated in the documentation ():

If set to 'condense':
Consecutive whitespaces inside a non-whitespace-only text node are condensed into a single space.

Since this is not a default setting in a new Vue application, it is recommended to remove it and check if that solves the issue.

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

The process of incorporating external JavaScript scripts into VueJS Components

I currently have two external scripts that need to be used for the payment gateways. At the moment, both scripts are placed in the index.html file. However, I prefer not to load these files at the beginning of the process. The payment gateway is only re ...

Incorporating a polygon into vue2-leaflet framework

I have been struggling to incorporate a MultiPolygon onto a leaflet map using vue2-leaflet without any success. The polygon coordinates are being generated from PostGIS. Is there a way to add a polygon to a vue2leaflet map? Sample code: fiddle: https:// ...

What is the most efficient way to transfer data from PHP Laravel to Vue.js and automatically update a Vue.js component whenever the data is modified?

New to Vue.js and feeling a bit lost about how reactivity works with it. I want to send data from PHP Laravel to a Vue.js component and have the component update automatically when the data changes. I've come across suggestions on Stack Overflow reco ...

``Are there any thoughts on how to troubleshoot display problems specifically on mobile

Whenever I use Safari on iOS for my web application, I encounter strange rendering issues. It's odd because the majority of the time everything functions as it should, but every now and then these bugs crop up with no discernible pattern. Examples th ...

Troubleshooting Vue template issues with updating values in the composition API

I am facing an issue with a functional component: export default defineComponent({ name: 'MovieOverview', components: { ExpandedMovieInformation, }, setup() { let toggleValue = false; const toggleExpandedMovieInformation = (m ...

Adding local JavaScript to a Vue component is a great way to enhance its functionality

I am currently working on integrating a homepage concept (Home.vue) into my project. The design is based on a template that I purchased, which includes CSS, HTML files, and custom JavaScript. While most of the CSS has been successfully imported, I am havin ...

I am having difficulty retrieving information from the Laravel API

I am struggling to retrieve data from my Laravel application and display it in Vue CLI. While I can see the response, I am encountering difficulties when trying to show it in the Vue application. https://i.stack.imgur.com/tCgrd.png Whenever I attempt to f ...

Tips for removing a row without impacting the rest of the rows

I'm currently developing a VueJs parent component with the ability to generate rows dynamically. This component invokes another component responsible for populating two dropdowns using axios - one for categories and the other for subcategories (with t ...

Harnessing the power of two-way data binding in VueJS

I am looking to utilize Vue's two-way data binding to dynamically update the values of amount and total. The price of a given product is fixed. When users modify the amount, the total = amount * total will be automatically calculated. Similarly, users ...

Guide on passing authorization header from Flask API to VueJS

I've been working on a login page that utilizes JWT for authorization. The backend authorization is functioning properly, but I am encountering an error when trying to authorize the page using axios from VueJS. The error message indicates "Missing aut ...

Check input validations in Vue.js when a field loses focus

So I've created a table with multiple tr elements generated using a v-for loop The code snippet looks like this: <tr v-for="(item, index) in documentItems" :key="item.id" class="border-b border-l border-r border-black text ...

The Quasar test fails to locate elements with a name tag>null<

I've encountered a strange issue while trying to conduct unit tests on my Quasar application. The problem seems to be that the test is unable to locate elements with the name tag, except for the q-route-tab components. I've experimented with diff ...

Developing a dynamic web application using the Django framework along with the Vue.js library and Highcharts for

I am currently working on a data visualization web app using Django, Highcharts, and JQuery. I have recently transitioned from JQuery to Vue JS and I am struggling with fetching JSON data from a specific URL. Below is the code snippet: Template <!doc ...

When you try to remove an element from an array by its index in Vue JS, the outcome may not be

Here is an array that I have: var hdr = ("name", "date", "start_time", "selling_item", "total_call", "end_time", "ad_num", "area", "order_num"); //this data comes from the database Now, I need to rename these array elements according to prope ...

Whenever a button is clicked in Vue.js 2, the $refs attribute is returning an empty object to me

My attempts to retrieve the value of a ref from my input in the console are proving unsuccessful as it keeps returning an empty object. I utilized the $emit function to pass the function from the child component to the parent component. When I tried cons ...

Why do referees attempt to access fields directly instead of using getters and setters?

I am facing an issue with my TypeScript class implementation: class FooClass { private _Id:number=0 ; private _PrCode: number =0; public get Id(): number { return this._Id; } public set Id(id: number) { this._Idprod ...

Is there a way to eliminate the shadow effect from the md-steppers tag in vue-material?

After using vue-material to create a stepper, I noticed that it includes a class called md-steppers-navigation which adds a box-shadow effect. I prefer not to have this shadow and am wondering how I can remove it. Any suggestions? ...

Set the Vue 3 Select-Option to automatically select the first option as the default choice

I am attempting to set the first select option as the default, so it shows up immediately when the page loads. I initially thought I could use something simple like index === 0 with v-bind:selected since it is a boolean attribute to select the first option ...

Rendering content on the server side and creating a cached version of the index.html file using Vuejs and Nodejs

Having multiple websites (site1.com, site2.com) connected to a single server poses an interesting challenge. I am able to capture the domain name when a user enters a site, and based on that domain name, I fetch appropriate JSON data from an API to display ...

Create a named scopedSlot dynamically

Looking to incorporate the following template into my component's render function, but struggling with how to do so. This is the current template structure: <template> <div> <slot name="item" v-for="item in filte ...