javascript - 如何在不同组件的vue js中实现平滑滚动?
问题描述
我正在尝试在 Vue 中使用不同的组件实现平滑滚动。像 About.vue 是主要组件,AboutHeader.vue 和 AboutContent.vue 是 About.vue 内部的子组件。
AboutHeader.vue
<template>
<div>
<h1> About Heading</h1>
<a href="#content">content</a>
</div>
</template>
AboutContent.vue
<template>
<div>
<h2> About Content</h2>
</div>
</template>
关于.vue 文件
<template>
<div>
<AboutHeader/>
<AboutContent id="content"/>
</div>
</template>
锚标签的点击滚动是有效的,但它不是平滑滚动,我尝试使用 vue2-smooth-scroll 但它不工作。
我把它放在我的 main.js 文件中。
import VueSmoothScroll from 'vue2-smooth-scroll'
Vue.use(VueSmoothScroll)
在 AboutHeader.vue 文件中
<a href="#content" v-smooth-scroll></a>
解决方案
推荐阅读
- javascript - 在本地将 Firestore 子集合导出为 CSV 或 JSON
- java - 页面对象模型类中的 NullPointerException
- python - Pandas 数据框将日期从 int64 更改为 datetime 中的日期
- linux - 即使登录有效,Pam_unix sshd 身份验证失败?
- php - 将运输标签打印到热敏打印机
- docker - 使用 docker 在 tensorflow 上调试的简单方法是什么?
- json - 使用代号一显示图像
- c# - if else condition in asp.net
- python - 创建文本图层 psd
- javascript - PDF 工具栏禁用