Vue.js 和 Vuetify 不同的数据操作方式

huangapple go评论70阅读模式
英文:

Vujs and Vuetify Different Data Manipulation

问题

Sure, here is the translated code part:

<v-simple-table>
  <thead>
    <tr>
      <th class="text-left">
        <v-card-subtitle><strong>请假</strong></v-card-subtitle>
      </th>
      <th class="text-left">
        <v-card-subtitle><strong>缺勤</strong></v-card-subtitle>
      </th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td v-for="conge in conges" :key="conge.id">
        {{ conge.dateDebut }} 到 {{ conge.dateFin }}
      </td>
      <td v-for="absence in absences" :key="absence.id">
        {{ absence.dateDebut }} 到 {{ absence.dateFin }}
      </td>
    </tr>
  </tbody>
</v-simple-table>

Is there anything else you need?

英文:

I want to manipulate data from different table (mariadb) in the same database, but idk how to make it good. It work with only single data but when there is more than 1 data it push it to right, and I want to make it vertically... Someone have a solution ? Vue.js 和 Vuetify 不同的数据操作方式

&lt;v-simple-table &gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th class=&quot;text-left&quot;&gt;
        &lt;v-card-subtitle&gt;&lt;strong&gt;Cong&#233;&lt;/strong&gt;&lt;/v-card-subtitle&gt;&lt;/th&gt;
      &lt;th class=&quot;text-left&quot;&gt;
        &lt;v-card-subtitle&gt;&lt;strong&gt;Absence&lt;/strong&gt;&lt;/v-card-subtitle&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr &gt;
      &lt;td v-for=&quot;conge in conges&quot; :key=&quot;conge.id&quot;&gt;
        {{ conge.dateDebut }}  &#224;  {{ conge.dateFin}}
      &lt;/td&gt;
      &lt;td v-for=&quot;absence in absences&quot; :key=&quot;absence.id&quot;&gt;
        {{ absence.dateDebut }}  &#224;  {{ absence.dateFin }}
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/v-simple-table&gt;

答案1

得分: 1

以下是代码的中文翻译部分:

<template>
  <v-simple-table>
    <thead>
      <tr>
        <th class="text-left">
          <v-card-subtitle>
            <strong>请假</strong>
          </v-card-subtitle>
        </th>
        <th class="text-left">
          <v-card-subtitle>
            <strong>缺席</strong>
          </v-card-subtitle>
        </th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="(data, index) in mergedData" :key="index">
        <td>{{ data.conge.dateDebut }} 到 {{ data.conge.dateFin }}</td>
        <td>{{ data.absence.dateDebut }} 到 {{ data.absence.dateFin }}</td>
      </tr>
    </tbody>
  </v-simple-table>
</template>
<script>
export default {
  data() {
    return {
      mergedData: []
    };
  },
  computed: {
    absences() {
      return [
        { id: 1, dateDebut: "2022-01-01", dateFin: "2022-01-02" },
        { id: 2, dateDebut: "2022-01-03", dateFin: "2022-01-04" }
      ];
    },
    conges() {
      return [
        { id: 1, dateDebut: "2022-02-01", dateFin: "2022-02-02" },
        { id: 2, dateDebut: "2022-02-03", dateFin: "2022-02-04" }
      ];
    }
  },
  created() {
    for (let i = 0; i < this.conges.length; i++) {
      this.mergedData.push({
        conge: this.conges[i],
        absence: this.absences[i]
      });
    }
  }
};
</script>

这是您提供的代码的中文翻译部分。

英文:

you can try this code :

&lt;template&gt;
  &lt;v-simple-table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th class=&quot;text-left&quot;&gt;
          &lt;v-card-subtitle&gt;
            &lt;strong&gt;Cong&#233;&lt;/strong&gt;
          &lt;/v-card-subtitle&gt;
        &lt;/th&gt;
        &lt;th class=&quot;text-left&quot;&gt;
          &lt;v-card-subtitle&gt;
            &lt;strong&gt;Absence&lt;/strong&gt;
          &lt;/v-card-subtitle&gt;
        &lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr v-for=&quot;(data, index) in mergedData&quot; :key=&quot;index&quot;&gt;
        &lt;td&gt;{{ data.conge.dateDebut }}  &#224;  {{ data.conge.dateFin }}&lt;/td&gt;
        &lt;td&gt;{{ data.absence.dateDebut }}  &#224;  {{ data.absence.dateFin }}&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/v-simple-table&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
  data() {
    return {
      mergedData: []
    };
  },
  computed: {
    absences() {
      return [
        { id: 1, dateDebut: &quot;2022-01-01&quot;, dateFin: &quot;2022-01-02&quot; },
        { id: 2, dateDebut: &quot;2022-01-03&quot;, dateFin: &quot;2022-01-04&quot; }
      ];
    },
    conges() {
      return [
        { id: 1, dateDebut: &quot;2022-02-01&quot;, dateFin: &quot;2022-02-02&quot; },
        { id: 2, dateDebut: &quot;2022-02-03&quot;, dateFin: &quot;2022-02-04&quot; }
      ];
    }
  },
  created() {
    for (let i = 0; i &lt; this.conges.length; i++) {
      this.mergedData.push({
        conge: this.conges[i],
        absence: this.absences[i]
      });
    }
  }
};
&lt;/script&gt;

huangapple
  • 本文由 发表于 2023年2月14日 22:01:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75448929.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定