Refs 用于引用特定的 DOM 元素。
提供缺少的代码,以便在安装应用程序时在第二个 <p> 标签中显示“Hello World”。
<template>
<p>This is just some text.</p>
<p @(9)>This is the initial text</p>
</template>
<script>
export default {
mounted() {
this.@(5).pEl.innerHTML = "Hello World!";
}
};
</script>
<template>
<p>This is just some text.</p>
<p ref="pEl">This is the initial text</p>
</template>
<script>
export default {
mounted() {
this.$refs.pEl.innerHTML = "Hello World!";
}
};
</script>
<template>
<p>This is just some text.</p>
<p ref='pEl'>This is the initial text</p>
</template>
<script>
export default {
mounted() {
this.$refs.pEl.innerHTML = "Hello World!";
}
};
</script>