-1👍
const value = document.querySelector('p#idNum').textContent
-1👍
Working Demo :
new Vue({
el: '#app',
data() {
return {
lesson: {
_id: 123
},
paragraphValue: ''
}
},
mounted() {
this.paragraphValue = document.getElementById('idNum').innerHTML;
console.log(this.paragraphValue);
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<p id="idNum">{{ lesson._id }}</p>
</div>
-1👍
use ref instead of id and you can call it like console.log(refs["idNum"])
<p ref="idNum">{{lesson._id}}</p>
Do not forget to import ref from vue
Source:stackexchange.com