I'd like to turn a div
into input box on click, so that the post (which is rendered inside a loop) can be edited.
Here is the button on the post:
<a @click="setFocusEdit(index)" v-if="isAuthor(post)" href="#" >Edit Me</a>
And the div
concerned:
<div :ref="'p' + index" class="post-description">
{{post.description}}
</div>
The method:
setFocusEdit(index) {
console.log('focusing on', index);
this.$refs['p' + index].focus();
},
But I get this error:
Uncaught TypeError: this.$refs[("p" + index)].focus is not a function
How can I fix this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…