'Unable to get the variable in my dom (vue.js)
<v-app>
<h1>This is students Page</h1>
<p>{{question}}</p>
</v-app>
</template>
<script>
import ChannelDetails from './ChannelDetails'
export default {
name: 'Student',
data: () => ({
question: ''
}),
created() {
var channel = ChannelDetails.subscribeToPusher();
channel.bind("data-add-event", function(data) {
console.log(data)
this.question = data.question;
console.log(this.question)
})
},
}
</script>
I am getting the question in my console but am unable to get it in the dom. can you please suggest to me a way out? thanks....
Solution 1:[1]
How to access the correct `this` inside a callback
Your "this" inside a callback might not be the correct "this", try using an arrow function, or refer to the link above for more help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bin Phan |
