With Vue.Js How can I call data from Backend into Modal in FrontEnd - vue.js

In the image below, I call the current version with the Component from the Result field, but I cannot print the cloned project to the modal on the right. If anyone has an idea on how to fix this I would be very happy.
// COMPARE ACTION
GetCompareListByProject() {
// var _projectNo = this.$route.params.name;
var _this = this;
axios
.post(
GetURL() +
"Electric/GetVersionListByProject/" +
"-" +
"/" +
this.CloneSourceProjectNo
)
.then((resp) => {
if (resp.data.Response == true) {
var revisionList = [];
var data = resp.data.Data;
for (var i = 0; i < data.length; i++) {
if (revisionList.indexOf(data[i].RevisionNo) < 0)
revisionList.push(data[i].RevisionNo);
}
_this.CloneModalList = {
Revisions: revisionList,
Data: data,
};
_this.CloneNewNumber = {
Revision: resp.data.Revision,
Version: resp.data.Version,
};
}
});
},
CompareVersion() {
axios
.post(
GetURL() +
"Electric/OpenElectricProjectById/" +
this.OpenModalSelected.Id
)
.then((resp) => {
console.log(resp.data);
this.$store.state.project.ProjectTab.filter(
(p) => p.title == "Electric"
)[0].form = resp.data.Data.InputMain[0];
this.$store.state.project.Models.Project.Transformer.Electric =
resp.data.Data.Electric;
this.$store.state.general.ProjectMessage =
"Opened Version R" +
resp.data.Data.InputMain[0].RevisionNo +
"V" +
resp.data.Data.InputMain[0].VersionNo;
this.$swal({
position: "top-end",
icon: "success",
title: "Project Opened",
showConfirmButton: false,
timer: 1500,
});
this.$store.state.general.isLoading = false;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<b-modal
size="xl modal-full"
id="modal-compare"
title="Compare Project"
ok-only
ok-variant="secondary"
ok-title="Cancel"
>
<b-card class="w-50 h-10" style="float: left">
<b-tabs class="tabList" v-model="tabIndex">
<b-tab
#click="SetTabType('Result')"
v-for="(elec, index) in $store.state.project.Models.Project
.Transformer.Electric"
:key="index"
:active="index == 0"
>
<!-- <template #title>
<span class="line-tab">|</span>
{{ GetResultPageTitle(elec, index) }}
</template> -->
<ResultParameters
:Electric="elec"
:InputMain="
$store.state.project.Models.Project.Transformer.InputMain[0]
"
style="overflow-x: auto"
>
</ResultParameters>
</b-tab>
</b-tabs>
</b-card>
<b-card class="w-50 h-10" style="float: right">
<b-form-group
class="mb-0"
label-cols-sm="12"
label-cols-xl="4"
label="Clone Project"
label-class="text-left"
>
<b-input-group>
<b-input v-model="CloneSourceProjectNo"></b-input>
<b-input-group-append>
<b-input-group-text
style="cursor: pointer"
#click="GetCompareListByProject"
><i class="fa fa-sync-alt"></i
></b-input-group-text>
</b-input-group-append>
<b-button
class="w-100 waterGreen"
style="margin-top: 5px"
#ok="CompareVersion"
:ok-disabled="CompareModalSelected == null"
>
<i class="fa fa-bars"></i> Compare
</b-button>
</b-input-group>
</b-form-group>
<div class="mt-2"></div>
<div
v-for="rev in CloneModalList.Revisions"
:key="rev"
class="tree-view"
>
<h5>R{{ rev }}</h5>
<div
class="tree-item"
v-for="vers in CloneModalList.Data.filter(
(x) => x.RevisionNo == rev
)"
:key="vers.Id"
>
<span :class="GetInput().Id == vers.Id ? 'font-weight-bold' : ''">
<i
class="fas fa-check-circle releasedVersIcon"
v-if="vers.ActiveVersion"
></i>
V{{ vers.VersionNo }} : {{ vers.Description }}
<b-radio
:value="vers"
v-model="CompareModalSelected"
style="width: 16px; float: right; margin-top: -1px"
></b-radio>
</span>
</div>
</div>
</b-card>
</b-modal>

Related

Vue js slider with left and right

export default {
name: 'MovieSlider',
data() {
return {
index: 0,
imgs: [
'https://7themes.su/_ph/40/303277371.jpg',
'https://7themes.su/_ph/23/730607462.jpg',
'https://7themes.su/_ph/23/730607462.jpg',
],
};
},
computed: {
sideSlide() {
return {
transform: `translateX(${-this.index * 100}vw)`,
};
},
},
methods: {},
left() {
this.index++;
if (this.index > this.imgs.length - 1) {
this.index = 0;
}
this.sideSlide;
},
right() {
this.index--;
if (this.index < 0) {
this.index = this.imgs.length - 1;
}
this.sideSlide;
},
};
<template>
<div class="carusel">
<div class="image-container imgs">
<button class="left buttons" #click="left">
<i class="fa-solid fa-angle-left"></i>
</button>
<div v-for="item in imgs" :key="item.id" :style="sideSlide">
<img :src="item" />
</div>
<button class="right buttons" #click="right">
<i class="fa-solid fa-chevron-right"></i>
</button>
</div>
<div class="popular_films">
<div class="content">
<p class="film_name">Film Name</p>
<p class="film_info">
<i class="fa-solid fa-star"></i>
<span>FIlm vote</span>
<span>Film time</span>
<span>Film year</span>
</p>
<span class="play_treiler"
>Trailer<i class="fa-solid fa-play"></i
></span>
</div>
</div>
</div>
</template>
Hi friends, I want to make slider with vue but something is going wrong, after pressing right or left i want to give a style(size) to image that slides to another image but something is going wrong, in here you can find all of the code that i used in this component, Thank you.

Data is not coming if i use async in vue js 3

I am implementing Quiz App but here I am facing an issue if I put static data in array the questions are coming.
Data is not coming if i use async in Vue JS 3
But If I Call data from the API the questions are not showing.
when I console the questions are showing in console and not showing in the front end.
For ref please find the attached code and image.
Home.vue (please see fetchQuestionsFromServer function)
<template>
<main class="flex h-screen items-center justify-center bg-gray-100">
<!-- quiz container -->
<QuizComplatePage v-if="endofQuiz" />
<div
class="overflow-hidden bg-white flex-none container relative shadow-lg rounded-lg px-12 py-6"
>
<img
src="#/assets/images/abstract.svg"
alt=""
class="absolute -top-10 left-0 object-none"
/>
<!-- contents -->
<div class="relative z-20">
<!-- score container -->
<div class="text-right text-gray-800">
<p class="text-sm leading-3">Score</p>
<p class="font-bold">{{score}}</p>
</div>
<!-- timer container -->
<div class="bg-white shadow-lg p-1 rounded-full w-full h-5 mt-4">
<div class="bg-blue-700 rounded-full w-11/12 h-full"
:style= "`width: ${timer}%`"
></div>
</div>
<!-- question container -->
<div
class="rounded-lg bg-gray-100 p-2 neumorph-1 text-center font-bold text-gray-800 mt-8"
>
<div class="bg-white p-5">
{{currentQuestion.question}}
</div>
</div>
<!-- options container -->
<div class="mt-8">
<!-- option container -->
<div v-for="(choice,item) in currentQuestion.choices" :key="item">
<div
class="neumorph-1 option-default bg-gray-100 p-2 rounded-lg mb-3 relative"
:ref="optionchosen"
#click="onOptionClick(choice,item)"
>
<div
class="bg-blue-700 p-1 transform rotate-45 rounded-md h-10 w-10 text-white font-bold absolute right-0 top-0 shadow-md"
>
<p class="transform -rotate-45">+10</p>
</div>
<div class="rounded-lg font-bold flex p-2">
<!-- option ID -->
<div class="p-3 rounded-lg">{{item}}</div>
<!-- option name -->
<div class="flex items-center pl-6">{{choice}}</div>
</div>
</div>
</div>
<!-- option container -->
</div>
<!-- progress indicator container -->
<div class="mt-8 text-center">
<div class="h-1 w-12 bg-gray-800 rounded-full mx-auto"></div>
<p class="font-bold text-gray-800">{{questionCounter}}/{{questions.length}}</p>
</div>
</div>
</div>
</main>
</template>
<script>
import { onMounted, ref } from 'vue'
import QuizComplatePage from './QuizCompleteOverlay.vue'
export default{
components: {
QuizComplatePage
},
setup(){
//data
let canClick = true
let score = ref(0)
let timer = ref(100)
let endofQuiz = ref(false)
let questionCounter = ref(0)
const currentQuestion = ref({
question: '',
answer: 1,
choices: [],
});
const questions = []
const loadQuestion = () =>{
canClick = true
timer.value=100
//Check question array had questions or not
if(questions.length > questionCounter.value){
currentQuestion.value = questions[questionCounter.value]
console.log('Current Question is : ', currentQuestion.value);
questionCounter.value++
}else{
endofQuiz.value = true
console.log('Out of Questions');
}
}
//methods
let itemsRef = []
const optionchosen = (element) =>{
if(element){
itemsRef.push(element)
}
}
const clearSelected = (divselected) =>{
setTimeout(()=>{
divselected.classList.remove('option-correct')
divselected.classList.remove('option-wrong')
divselected.classList.add('option-default')
loadQuestion()
},1000)
}
const onOptionClick = (choice,item) =>{
if(canClick)
{
const divContainer = itemsRef[item]
const optionId = item+1
if(currentQuestion.value.answer ===optionId){
console.log('You are Correct');
score.value += 10
divContainer.classList.add('option-correct')
divContainer.classList.remove('option-default')
}else{
console.log('You are Wrong');
divContainer.classList.add('option-wrong')
divContainer.classList.remove('option-default')
}
timer.value=100
canClick=false
//to go next question
clearSelected(divContainer)
console.log(choice,item);
}else{
console.log('Cant Select Option');
}
}
const countDownTimer = () =>{
let interval= setInterval(()=>{
if(timer.value>0){
timer.value--
}else{
console.log('Time is over');
clearInterval(interval)
}
},150)
}
const fetchQuestionsFromServer = async function(){
fetch('https://opentdb.com/api.php?amount=10&category=18&type=multiple')
.then((res) =>{
return res.json()
})
.then((data) =>{
const newQuestions = data.results.map((serverQuestion) =>{
const arrangedQuestion = {
question: serverQuestion.question,
choices: '',
answer: ''
}
const choices = serverQuestion.incorrect_answers
arrangedQuestion.answer = Math.floor(Math.random() * 4 + 1)
choices.splice(arrangedQuestion.answer-1 , 0 , serverQuestion.correct_answer)
arrangedQuestion.choices = choices
return arrangedQuestion
})
console.log('new formated questions' , newQuestions);
questions.value = newQuestions
loadQuestion()
countDownTimer()
console.log('questions: =>' , questions.value);
})
}
//lifecycle hooks
onMounted(() =>{
fetchQuestionsFromServer()
})
//return
return {
timer,
currentQuestion,
questions,
score,
questionCounter,
loadQuestion,
onOptionClick,
optionchosen,
endofQuiz,
}
}
}
</script>
<style scoped>
.neumorph-1 {
box-shadow: 6px 6px 18px rgba(0, 0, 0, 0.09), -6px -6px 18px #ffffff;
}
.container {
max-width: 400px;
border-radius: 25px;
}
</style>
QuizComplatePage.vue
<template>
<div class="w-screen h-screen absolute z-30 bg-white bg-opacity-30 flex justify-center items-center">
<div class="bg-green-700 p-4 text-center text-white">
<p class="font-bold text-2xl">All DOne!</p>
<p class="my-4 font-bold text-3xl">100% Score</p>
<!-- Buttons -->
<div class="flex justify-center">
<div class="rounded-full py-1 w-28 border cursor-pointer hover:text-black hover:bg-white">Done</div>
<div class="rounded-full py-1 w-28 border cursor-pointer hover:text-black hover:bg-white">Retry</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'QuizComplatePage'
}
</script>
<style>
</style>
Image.
You are not using value when you need to:
For instance look in this function
questions.length should be questions.value.length
Also currentQuestion.value = questions.value[questionCounter.value]
Start by fixing that.
Everything that is a ref in your setup needs to be accessed by .value in anything inside your setup. Outside your setup it will have this and can be treated normally. Mixing these two up is the most common error.
const loadQuestion = () =>{
canClick = true
timer.value=100
//Check question array had questions or not
if(questions.value.length > questionCounter.value){
currentQuestion.value = questions.value[questionCounter.value]
console.log('Current Question is : ', currentQuestion.value);
questionCounter.value++
}else{
endofQuiz.value = true
console.log('Out of Questions');
}
}
Here is my solution
let questions = []
questions = newQuestions
Now I am able to load questions.

How to rotate single chevron on accordion in vue?

I am using vue chevron in accordion inside for loop. When I am clicking a single dropdown, all other chevrons are rotating. How to rotate the specific chevron for the clicked dropdown in vue ? I am using vue chevron package from https://ispal.github.io/vue-chevron/ . My dropdown looks like this -
My vue code:
<div class="accordion" id="accordionExample">
<div
v-for="(data, index) in topicList"
:key="index"
class="card"
>
<div class="card_header" id="headingOne">
<h2 class="mb-0">
<div
class="btn btn-topic example text-left collapsed"
#click="toggle"
type="button"
data-toggle="collapse"
:data-target="'#collapseOne' + index"
aria-expanded="true"
aria-controls="collapseOne"
>
<vue-chevron
:point-down="pointDown"
:duration="duration"
:thickness="thickness"
:angle="angle"
:round-edges="roundEdges"
/>
{{ data.title }}
</div>
</h2>
</div>
<div
:id="'collapseOne' + index"
class="collapse"
aria-labelledby="headingOne"
data-parent="#accordionExample"
>
<div class="card-body">
<ul
v-for="(data, index) in topicList[index].lessons"
:key="index"
#click="getContent(data.lessonId)"
class="list-group py-1"
>
<li class="list-group-item list-style">
{{ data.title }}
</li>
</ul>
</div>
</div>
</div>
</div>
<script>
import VueChevron from "vue-chevron"
export default{
components:{ VueChevron }
data(){
return{
pointDown: false,
thickness: 8,
duration: 500,
angle: 40,
roundEdges: true,
easing: function n(t) {
return t;
}
}
methods: {
toggle() {
this.pointDown = !this.pointDown;
},
}
}
courseAccess() {
this.$axios
.get(this.$api + "api/v1/courses/" + this.courseId, {
headers: {
Authorization: "Bearer " + localStorage.getItem("_utoken"),
},
})
.then((response) => {
// this.topicList = response.data.data.topics.map((element) => {
// return { ...element, pointDown: true };
// });
this.topicList = response.data.data.topics
this.firstTopic = response.data.data.topics[0].lessons[0].lessonId;
this.getFirstContent(this.firstTopic);
this.loadTopics = true;
});
},
All vue-chevron are binding there point-down prop to the same boolean. You could try to use an array of boolean instead and change your toggle method.
<div class="accordion" id="accordionExample">
<div
v-for="(data, index) in topicList"
:key="index"
class="card"
>
<div class="card_header" id="headingOne">
<h2 class="mb-0">
<div
class="btn btn-topic example text-left collapsed"
#click="toggle(index)"
type="button"
data-toggle="collapse"
:data-target="'#collapseOne' + index"
aria-expanded="true"
aria-controls="collapseOne"
>
<vue-chevron
:point-down="pointDown[index]"
:duration="duration"
:thickness="thickness"
:angle="angle"
:round-edges="roundEdges"
/>
{{ data.title }}
</div>
</h2>
</div>
<div
:id="'collapseOne' + index"
class="collapse"
aria-labelledby="headingOne"
data-parent="#accordionExample"
>
<div class="card-body">
<ul
v-for="(data, index) in topicList[index].lessons"
:key="index"
#click="getContent(data.lessonId)"
class="list-group py-1"
>
<li class="list-group-item list-style">
{{ data.title }}
</li>
</ul>
</div>
</div>
</div>
</div>
<script>
import VueChevron from "vue-chevron"
export default{
components:{ VueChevron }
data(){
return{
pointDown: [],
thickness: 8,
duration: 500,
angle: 40,
roundEdges: true,
easing: function n(t) {
return t;
}
}
methods: {
toggle(index) {
this.pointDown[index] = !this.pointDown[index];
},
}
}
EDIT
The problem discussed in the comments could be caused by reactivity issues. To solve these we are trying to initialize pointDown with an array of the correct size.
courseAccess() {
this.$axios
.get(this.$api + "api/v1/courses/" + this.courseId, {
headers: {
Authorization: "Bearer " + localStorage.getItem("_utoken"),
},
})
.then((response) => {
// this.topicList = response.data.data.topics.map((element) => {
// return { ...element, pointDown: true };
// });
this.topicList = response.data.data.topics;
this.pointDown = new Array(this.topicList.length).fill(false);
this.firstTopic = response.data.data.topics[0].lessons[0].lessonId;
this.getFirstContent(this.firstTopic);
this.loadTopics = true;
});
},

vue-test-utils not updating component after click

I am using vue-test-utils/mocha-webpack/expect to test the following component:
<template>
<div>
<div id="agent-customer-container" class="top-tabs" v-if="agentName || customerName || miniBasket">
<div v-if="agentName || customerName">
<div class="text-primary bg-white top-tabs__item px-5" id="customer-slot" v-if="customerName" #click="customerDetailShow = !customerDetailShow">
<span>
<i class="fa fa-user-circle fa-2x mr-3"></i>
{{ customerName }}
</span>
<i :class="'fa fa-caret-'+(customerDetailShow?'up':'down')" id="customer-caret"></i>
</div>
<div class="text-primary top-tabs__item top-tabs__item--light px-5" id="agent-slot" v-if="agentName">
{{ agentName }}
</div>
</div>
<div class="top-tabs__mini-basket text-primary px-5" v-if="miniBasket && !loading">
<span v-if="firstEnquiry !== null && firstEnquiry.cruise !== null && firstEnquiry.cruise !== undefined">
<span id="first-enquiry-cruise-summary">{{ firstEnquiry.cruise.name }} ({{ firstEnquiry.cruise.code }})</span>
- <span class="text-semibold">£XX.XX</span>
</span>
<span id="toggle__mini-basket" :class="[{'fa-counter': (enquiryCount > 0), 'mini-basket__count' : (enquiryCount > 0)}, 'fa-stack v-top ml-3 cursor-pointer']" #click="toggleMiniBasket" :data-count="enquiryCount">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fas fa-shopping-cart fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="customer-detail bord-rgt" v-show="customerDetailShow">
<div class="row p-5 bord-btm" v-for="i in 2" :key="i">
<div class="col-sm-6">
<p>Sydney to Hong Kong</p>
<p>Text<br>Text</p>
</div>
<div class="col-sm-6">
<p><strong>Grade data</strong>
<br>
Lorem ipsum
</p>
</div>
</div>
<div class="row p-5 bg-primary customer-detail__footer">
<div class="row">
<div class="col-sm-6">
Text
</div>
<div class="col-sm-6 text-right text-bold">
Total £1000
</div>
</div>
</div>
</div>
<div class="mini-basket-detail bord-lft" v-if="miniBasketDetailShow">
<div v-if="myEnquiry !== false && myEnquiry !== undefined && myEnquiry['cruise_enquiries'] !== undefined && firstEnquiry !== null && firstEnquiry.cruise !== null">
<div class="row p-5 bord-btm" v-for="(cruiseEnquiry, cruiseEnquiryIndex) in myEnquiry['cruise_enquiries']" :key="cruiseEnquiry.id">
<div class="col-sm-12 text-sm" v-if="cruiseEnquiry.cruise !== undefined">
<cruise-enquiry
:cruise-name="cruiseEnquiry.cruise.name"
:cruise-code="cruiseEnquiry.cruise.code"
:ship-name="cruiseEnquiry.cruise.ship.name"
:departure-port-name="cruiseEnquiry.cruise.departure_port.name"
:departure-date="new Date(cruiseEnquiry.cruise.departure_date)"
:duration="cruiseEnquiry.cruise.duration"
:cruise-enquiry-cabins="cruiseEnquiry.cruise_cabin_cruise_enquiry"/>
</div>
</div>
</div>
<div v-else>
<div class="row p-5 bord-btm">
<div class="col-sm-12 text-sm">
<p>Your itinerary is currently empty. Please start by selecting a cruise.</p>
</div>
</div>
</div>
<div id="toggle__mini-basket--close" class="row p-3 bg-primary customer-detail__footer text-center cursor-pointer d-block" #click="miniBasketDetailShow = false">
<caret :up="true" additional-classes="fa-2x"></caret>
</div>
</div>
<span class="float-right"></span>
</div>
</div>
</template>
<script>
import Caret from "./Caret";
import CruiseEnquiry from "./enquiry-panel/CruiseEnquiry";
export default {
name: "EnquiryPanel",
components: {
CruiseEnquiry,
Caret,
},
props: {
loading: {
type: Boolean,
required: false,
default: false,
},
customerName: {
type: String,
required: false,
default: ''
},
agentName: {
type: String,
required: false,
default: ''
},
myEnquiry: {
type: Object|Boolean,
required: false,
default: false,
},
miniBasket: {
type: Boolean,
required: false,
default: false,
}
},
data() {
return {
customerDetailShow: false,
miniBasketDetailShow: false,
firstEnquiry: null,
enquiryCount: 0,
miniBasketCabinNumber: 0,
}
},
watch: {
myEnquiry: {
deep: true,
immediate: true,
handler(newValue) {
if (this.myEnquiry !== false && this.myEnquiry['cruise_enquiries'] !== undefined && this.myEnquiry['cruise_enquiries'][0] !== undefined) {
this.firstEnquiry = this.myEnquiry['cruise_enquiries'][0];
for (let i = 0; i <= (this.myEnquiry['cruise_enquiries'].length - 1); i++) {
if (this.myEnquiry['cruise_enquiries'][i].cruise !== undefined && this.myEnquiry['cruise_enquiries'][i].cruise !== null) {
this.setEnquiryCount(this.enquiryCount + 1);
}
}
}
}
}
},
methods: {
setEnquiryCount(count) {
this.enquiryCount = count;
},
toggleMiniBasket() {
this.miniBasketDetailShow != this.miniBasketDetailShow;
}
}
}
</script>
When I click on #toggle__mini-basket I expect miniBasketDetailShow to be set to true (defaults to false on mount) and the basket should show (using `v-if="miniBasketDetailsShow" on the element).
This is my test for it:
import {createLocalVue, shallowMount, mount} from '#vue/test-utils';
import expect from 'expect';
import EnquiryPanel from '~/components/EnquiryPanel';
import VueMoment from "vue-moment";
describe('EnquiryPanel', () => {
let localVue;
beforeEach(() => {
localVue = createLocalVue();
localVue.use(VueMoment);
});
// If a user clicks on the mini basket icon and the basket panel is not open, the basket panel should open
it('opens mini basket if user clicks icon and basket is not open', () => {
let component = shallowMount(EnquiryPanel, {
localVue,
propsData: {
miniBasket: true
}
});
expect(component.vm.miniBasket).toBe(true);
expect(component.vm.miniBasketDetailShow).toBe(false);
component.find('#toggle__mini-basket').trigger('click');
component.vm.$forceUpdate();
expect(component.vm.miniBasketDetailShow).toBe(true);
});
});
This is a simple test so I'm unsure what is going wrong. The result is as follows:
3) EnquiryPanel
opens mini basket if user clicks icon and basket is not open:
Error: expect(received).toBe(expected) // Object.is equality
Expected: true
Received: false
at Context.eval (webpack-internal:///./tests/Javascript/EnquiryPanel.spec.js:62:86)
I would expect this test to be passing. I have tried making the shallowMount be async with sync: false. I have also tried adding in await component.vm.$nextTick but no luck. Any help would be appreciated.
The error was with the toggleMiniBasket method:
this.miniBasketDetailShow != this.miniBasketDetailShow;
should be
this.miniBasketDetailShow = !this.miniBasketDetailShow;

vue+bulma Tabs Error:'openTab' is defined but never used

I would like to create a tab using vue and bulma, but I'm getting the following error:
error: 'openTab' is defined but never used (no-unused-vars) at
code:
<template>
<div>
<div class="tabs is-centered">
<ul>
<li class="tab is-active" onclick="openTab(e,'adult')"><a>Adult</a></li>
<li class="tab" onclick="openTab(e,'card')"><a>Card</a></li>
<li class="tab" onclick="openTab(e,'food')"><a>Food</a></li>
</ul>
</div>
<div id="adult" class="content-tab">
<img :src="require(`../../static/dst/${parentData.file_name}`)">
<div v-bind:style="{ color: `${parentData.font_color}`}">
{{parentData.info_text}}<br>
{{parentData.rate_adult}}{{parentData.part_name}}<br>
{{parentData.rate_part}}
</div>
</div>
<div id="card" class="content-tab" style="display: none">
<div :style="{ color: `${parentData.card_color}`}">
{{parentData.card_text}}
</div>
</div>
<div id="food" class="content-tab" style="display: none">
{{parentData.class_name}}
</div>
</div>
</template>
<script>
export default {
name: 'Child',
props: ['parentData'],
openTab(e, tabName) {
var i, x, tablinks;
x = document.getElementsByClassName("content-tab");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tab");
for (i = 0; i < x.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" is-active", "");
}
document.getElementById(tabName).style.display = "block";
e.currentTarget.className += " is-active";
}
}
</script>
                               
I want to find the answer to this problem.
Tap function does not apply.
Process:
Upload an image
Return json contents
Check by tap
Can you tell me what the error is?
Your openTabs function should be part of methods. So:
props: {},
methods: {
openTab()
}
More information here: https://v2.vuejs.org/v2/guide/events.html#Method-Event-Handlers