i am using vue 2.x
i have a html looks like:
<body> <div id="myDiv"> <input type="text" v-model="input" @click="showPopup"/> <div id="popupDiv" ....> <textarea v-model="textarea" ref="popup"></textarea> </div> </div> <script> myVM = new Vue({ name: 'myVM', el: 'myDiv', data() { return { input: '', textarea: '' } }, methods: { showPopup() { show popup dialog } } }) </script> </body>
when user click this input
, the popup dialog will be shown.
now i want the textarea
of popup dialog get focus automatically when popup dialog shown, so i tried to use this.$refs.popup.focus()
in showPopup()
, but it doesn't works.
没有评论:
发表评论