The table
The data that is in the Database it is only separated by commas.
JavaScript
x
11
11
1
Hepatitis A IgM Antibody (Anti-HAV IgM),
2
Hepatitis A Total Antibody (Anti-HAV Total),
3
Hepatitis B Core Antibody (Anti HBc Total),
4
Hepatitis B Core IgM Antibody (Anti-HBc IgM),
5
Hepatitis B Envelop Antibody (Anti-HBe),
6
Hepatitis B Envelop Antigen (HBeAg),
7
Hepatitis B Surface Antibody (Anti-HBs),
8
Hepatitis B Surface Antigen,
9
Hepatitis C Antibody (Anti-HCV),
10
Qualitative (HBsAg)
11
Frontend structure.
My code:
JavaScript
1
20
20
1
<q-list
2
v-for="specificPackage in specificPackages"
3
v-bind:key="specificPackage.id"
4
class="q-pa-md"
5
bordered
6
>
7
<q-card-section horizontal>
8
<q-card-section class="q-pt-xs">
9
<div class="text-h6 q-pt-md text-black" caption>
10
LABORATORY TESTS:
11
</div>
12
<div class="text-subtitle1 q-pt-md packageitem">
13
{{ specificPackage.packageitem }}
14
</div>
15
</q-card-section>
16
</q-card-section>
17
</q-card>
18
<q-separator />
19
</q-list>
20
How can I achieve this?
Advertisement
Answer
First split string into array and then loop the array
JavaScript
1
22
22
1
<q-list
2
v-for="specificPackage in specificPackages"
3
v-bind:key="specificPackage.id"
4
class="q-pa-md"
5
bordered
6
>
7
<q-card-section horizontal>
8
<q-card-section class="q-pt-xs">
9
<div class="text-h6 q-pt-md text-black" caption>
10
LABORATORY TESTS:
11
</div>
12
<div class="text-subtitle1 q-pt-md packageitem">
13
<li v-for="(packageitem, i) in specificPackage.packageitem.split(',')" :key="i">
14
{{packageitem}}
15
/li>
16
</div>
17
</q-card-section>
18
</q-card-section>
19
</q-card>
20
<q-separator />
21
</q-list>
22