I can't get the textContent
from blink and change it. If I try the same with tag or div tag then it works fine.
<b-link :ref="index" v-b-toggle="`${index}`" @click="changeText(index)" >View More</b-link> changeText(index) { console.log(this.$refs[index][0].textContent); // undefined }
P粉5961919632024-03-28 00:53:53
The difference between
<div />
and <b-link />
is that the former is the actual native HTML markup, while the latter provides a certain degree of Abstract components. To learn more, I recommend reading Native Web Components and their Vue counterparts.
To change the contents of <b-link />
, you must use Vue's reactivity:
let buttonText = 'View More';{{ buttonText }} changeText(index) { console.log(viewMore); // undefined viewMore = 'View Less'; }
P粉5790084122024-03-28 00:13:26
I found how to do this from vue js test case Usually this works
console.log(this.$refs[index][0].textContent);
But since bootstrap-vue will return the vue component to access its elements, we need to use $el to access its properties.
console.log(this.$refs[index][0].$el.textContent);