Answer the question
In order to leave comments, you need to log in
Why is the code not working, Vue.js?
I just started to understand Vue.js, so don't judge too harshly. There was such a problem: the method does not work pickFont
. Here is the JS:
var constructorSection = new Vue({
el: '.constructorSection',
data: {
sign: '',
signStyle: {
fontFamily: 'Montserrat, sans-serif'
},
FPisActive: false,
currentFont: 'Выберите шрифт надписи'
},
methods: {
pickFont: function (font) {
fontFamily: font,
currentFont = font,
FPisActive = false
}
}
})
<input type="text" class="signInput" placeholder="Введите вашу надпись" v-model="sign">
<h4>Шрифт</h4>
<div class="fontPicker" id="fontPicker" v-bind:class="{ opened: FPisActive }" v-on:click="FPisActive = true">
<div class="FP-Placeholder" id="FP-Placeholder" v-bind:class="{ opened: FPisActive }">
{{ currentFont }}
<img src="img/expandArrow.svg" alt="" style="float: right; margin-right: 15px;">
</div>
<div class="FP-Item" id="FP-1" v-bind:class="{ opened: FPisActive }" v-on:click="pickFont('Academia')">Academia</div>
</div>
alert(Что-то)
, then it will issue a notification, skipping everything that was before. Answer the question
In order to leave comments, you need to log in
It seems to me that you need to understand JS first
. Consider your method line by line:
fontFamily: font,
// создали метку fontFamily, которая здесь бесполезна,
// далее бесполезное обращение к переменной,
// далее оператор запятая
currentFont = font,
// тут вроде бы должны присвоить значение font в currentFont
// так как currentFont нигде не объявлено - будет ошибка
// ну и опять оператор запятая, а значит не фига в currentFont не будет font
FPisActive = false
// а будет там результат вот этого выражения, то есть false
// опять же FPisActive не объявлено - ошибка
pickFont: function (font) {
this.signStyle.fontFamily = font;
this.currentFont = font;
this.FPisActive = false;
}
Not a Vue connoisseur, I’m also just learning, but I’ll assume that something is wrong with the method:
pickFont: function (font) {
return { fontFamily: font,
currentFont: font,
FPisActive: false
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question