Exploring the code snippet provided below:
new Vue({
el: '#app',
computed: {
myMessage: function() {
return "hello";
}
},
data: {
message: this.myMessage
},
mounted: function() {
console.log(this.myMessage);
}
})
<script src="https://unpkg.com/vue"></script>
<div id="app>
<p>{{ message }}</p>
</div>
https://jsfiddle.net/hk49eL38/
Upon replacing:
this.myMessage
with a string (such as "Hello world"), the correct rendering is achieved.
However, when using this.myMessage
, the text does not render.
What could be causing this issue?