Vue 实现抖音动态评论点击隐藏功能 - 简单易懂教程
<template>
<div>
<!-- 动态内容 -->
<div>
...
</div>
<pre><code><!-- 评论 -->
<div v-if="isCommentsVisible">
...
</div>
<!-- 查看评论按钮 -->
<button @click="hideComments" v-if="!isCommentsVisible">查看评论</button>
</code></pre>
</div>
</template>
<script>
export default {
data() {
return {
isCommentsVisible: false
};
},
methods: {
hideComments() {
this.isCommentsVisible = true;
}
}
};
</script>
<p>通过以上步骤,点击一次查看评论按钮后,评论会显示出来,再次点击按钮则会隐藏评论。</p>
原文地址: https://www.cveoy.top/t/topic/pD8z 著作权归作者所有。请勿转载和采集!