What is the method for placing a title in the initial column with the help of v-simple-table from Vuetify.js?

I am interested in using the v-simple-table UI component from Vuetify.js to create a table similar to the one shown below.

https://i.sstatic.net/QNdpJ.png

After creating the code in codesandbox and previewing the output, I noticed that the title is not aligned properly. HTML↓

    <div id="app">
  <v-app id="inspire">
    <v-simple-table>
      <template v-slot:default>
        <thead>
          <tr>
            <th class="text-left">
              Name
            </th>
            <th class="text-left">
              Calories
            </th>
          </tr>
        </thead>
        <tbody>
          <tr
            v-for="item in desserts"
            :key="item.name"
          > 
            <th>{{ item.id }}</th>
            <td>{{ item.name }}</td>
            <td>{{ item.calories }}</td>
          </tr>
        </tbody>
      </template>
    </v-simple-table>
  </v-app>
</div>

Vue.js↓

    new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data () {
    return {
      desserts: [
        {
          id:1,
          name: 'Frozen Yogurt',
          calories: 159,
        },
        {
          id:2,
          name: 'Ice cream sandwich',
          calories: 237,
        },
        {
          id:3,
          name: 'Eclair',
          calories: 262,
        },
        {
          id:4,
          name: 'Cupcake',
          calories: 305,
        },
        {
          id:5,
          name: 'Gingerbread',
          calories: 356,
        },        
      ],
    }
  },
})

Output Image↓ https://i.sstatic.net/Gr9qN.png

I would appreciate any advice on how to resolve this issue.

Answer №1

You currently have two cells in the header section and three cells in the body section

To fix this, simply add another cell to the header section

<v-simple-table>
  <template v-slot:default>
    <thead>
      <tr>
        <th /> <!-- added empty header to re-align columns -->
        <th class="text-left">
          Name
        </th>
        <th class="text-left">
          Calories
        </th>
      </tr>
    </thead>
    <tbody>
      <tr
        v-for="item in desserts"
        :key="item.name"
      > 
        <th>{{ item.id }}</th>
        <td>{{ item.name }}</td>
        <td>{{ item.calories }}</td>
      </tr>
    </tbody>
  </template>
</v-simple-table>

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

vee-validate remains consistent in its language settings

Having trouble changing the error message in vee-validate, any suggestions on how to fix this? import VeeValidate from "vee-validate"; import hebrew from "vee-validate/dist/locale/he"; Vue.use(VeeValidate, { locale: "he", dictionary: { he: { me ...

Developing a Mongoose organization/class framework?

Currently, I'm in the process of developing a web application using Node.js, Express, and Mongoose/MongoDB. An important query has arisen regarding how to effectively organize and structure methods related to Mongoose. It's necessary for me to u ...

Adjust the height of column divs to equal the height of their parent container

Looking for a solution: I have multiple divs in a column layout and I want them to expand to match the original height of the parent. The parent's height is not fixed as it is part of a flex-based page design. Can this be done? In the example provid ...

jQuery and Ajax are facing a challenge in replacing HTML

Imagine a scenario where there is a button on a website that, when clicked, replaces a paragraph (<p>) with a header (<h1>). Unfortunately, the code to make this functionality work seems to be faulty: index.html <head> <script s ...

Tips for inserting a new choice into the v-select component of Vuetify

I need help loading data into a v-select using an API. I am attempting to include a new option labeled "all" with a value of 0, but the code I've tried doesn't seem quite right. Are there any alternative methods I could use to achieve this? ...

What is the reason behind only the initial click boosting the vote count while subsequent clicks do not have the same

In this snippet of code: //JS part echo "<script> function increasevotes(e,location,user,date,vote) { e.preventDefault(); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState ...

Has the Soundcloud web widget API become obsolete?

I am currently working with the SoundCloud widget API (). My main goal is to retrieve information about the tracks within a set. Unfortunately, it seems like I am only able to utilize the methods widget.getSounds() and widget.getCurrentSound successfully ...

creating sleek animations with Pixi.js for circular shapes

Is it possible to create smooth animations on circles or sprites similar to D3.js hits in Leaflet? https://drive.google.com/file/d/10d5L_zR-MyQf1H9CLDg1wKcvnPQd5mvW/view?usp=sharing While D3 works well with circles, the browser freezes. I am new to Pixi. ...

ngOnChanges will not be triggered if a property is set directly

I utilized the modal feature from ng-bootstrap library Within my parent component, I utilized modalService to trigger the modal, and data was passed to the modal using componentInstance. In the modal component, I attempted to retrieve the sent data using ...

How can one go about incorporating the feature "updating list upon clicking a label" on a webpage?

On my website, I currently display a comprehensive list of publications. However, I am looking to organize these publications by various research topics using labels. Ideally, when clicking on a specific label, only the papers related to that topic will be ...

Challenges with v-autocomplete in Vuetify.js

I am currently working with the v-autocomplete component and finding it somewhat rigid in terms of customization. I am hoping someone can provide some insight on this issue. Is there a way to have a default display text value in the input when the page fi ...

Firefox does not support jQuery AJAX functionality, unlike Internet Explorer where it works smoothly

Can anyone help me figure out how to ensure that this code works smoothly on both IE and Firefox? The confirm prompts are functioning in Firefox, but the AJAX request isn't triggering. According to Firebug, there's an error at line 9631 of jquery ...

Exploring ways to style font families for individual options within ng-options

I am looking to display a combobox where each option has a different font. While using the ng-options directive in AngularJS to populate the options for a <select> tag, I am struggling to set the font-family for individual options. $scope.reportFon ...

What is the best way to style radio boxes in HTML to resemble checkboxes and display X's when selected?

I'm looking to create a form with radio boxes that resemble checkboxes and display a glyphicon x when selected. I've experimented with various solutions such as: input[type="radio"] { -webkit-appearance: checkbox; /* Chrome, ...

Problem with Express server not fetching or applying public stylesheet

As I delve into the world of serving pages with node, express, and ejs, I encountered an issue with linking a stylesheet to my index.ejs file using a public folder. Despite setting up the link correctly in the HTML code, the styles were not loading when I ...

Did the IBM MobileFirst client miss the call to handleFailure?

I am currently utilizing the IBM MFP Web SDK along with the provided code snippet to send challenges and manage responses from the IBM MobileFirst server. Everything functions properly when the server is up and running. However, I have encountered an iss ...

Receiving the error notification from a 400 Bad Request

I'm having trouble showing the errors returned from an API on my Sign up form when a user submits invalid data. You can check out the error response in the console here: console ss This is my approach in RegisterComponent.ts: onSubmit() { this.u ...

The onClick function is failing to work properly, and I need to pass the value of 'cid' based on the result of the button

Is it possible to pass the 'courseid' to local storage when a button is clicked? I am having trouble with onclick not working. How can I retrieve the relevant 'courseid' in the onclick function based on the button clicked? handleClick ...

What is the process for moving entered data from one text box to another text box when a checkbox is selected?

I need help with a function that reflects data entered in one text box to another text box when a checkbox is ticked. The checkbox is initially checked and the values should change when it is unchecked and then checked again. Currently, the code is only ou ...

What is the process for incorporating beforeAnimate and afterAnimate callbacks into a custom jQuery plugin?

Let's imagine I have developed a plugin: // creating the plugin (function($){ $.fn.myPlugIn = function(options){ defaults = { beforeAnimate : function(){}, afterAnimate : function(){} ...