Answer the question
In order to leave comments, you need to log in
How to expand infoblock text on click?
Good day!
I have info blocks associated with markers on my google map. It is necessary that their text is hidden in this form "...", and when pressed, its information appears.
I came up with this trivial solution:
<gmap-info-window v-if="m.data.length > 0" @click="const text = m.data">{{ text === undefined ? '...' : text }}</gmap-info-window>
Answer the question
In order to leave comments, you need to log in
You, comrade, do not seem to understand:
a) how const works;
b) how inline event handlers work;
c) how Vue works.
a) const is only valid within a block.
b) The code written inline in the handler is just the body of the anonymous function. The function creates its own scope, which means that considering point a, the declared variable is not visible anywhere else.
c) Your template is compiled (Vue.compile to help you) into something like this function
function anonymous() {
with(this) {
return m.data.length > 0 ? _c("gmap-info-window", {
on : {
"click" : function($event$jscomp$0) {
const text$jscomp$10 = m.data;
}
}
}, [_v(_s(text === undefined ? "..." : text))]) : _e();
}
}
and it is quite obvious that nothing should work. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question