无法解决指令:滚动到vue-scrollto

发布于 2025-02-08 16:39:03 字数 1155 浏览 2 评论 0原文

我正在使用VUE JS(我是VUE JS上的新手)制作Web应用程序,特别是Vue2.x。我想单击菜单的元素,然后滚动到该元素。我曾想过使用此工具 https://vue-scrollto.netlify.app/examples/examples/ 正是我想做的。

问题在于,当我重复与示例中的代码相同时,我会收到错误“ [Vue Warn]:无法解决指令:滚动到 ”。这是我的代码:

<div :class="{subelementos: isOpenAndroid}">
        <div class="subelementos2">
          <p v-scroll-to="'#prueba'" class="subelementos3" @click="menuClick('android')">Principios</p>

        </div>
</div>

然后在另一个组件中:

<div id="prueba">
      <p>TEXTEXT</p>
</div>

我不知道有人是否熟悉此工具。我想我缺少一些重要的东西。

PS:也许是一个愚蠢的问题(对此很抱歉),但是,您认为必须使用NUXTJS吗?在工具的官方页面上,我认为是可选的 https:/ /vue-scrollto.netlify.app/docs/#nuxt-js

----编辑----

HTML,CSS和JS在同一文件中,特别是在.vue文件上。我认为也许我必须将外部库导入到我的.VUE文件中。

I am making a web application with Vue js(i am a newbie on vue js), specifically Vue 2.x. I want to click in an element of a menu, and then scroll to the that element. I have thought to use this tool https://vue-scrollto.netlify.app/examples/ as it is exactly what i want to do.

The problem is that when I repeat the same the code as in the examples, I receive the error "[Vue warn]: Failed to resolve directive: scroll-to". Here is my code:

<div :class="{subelementos: isOpenAndroid}">
        <div class="subelementos2">
          <p v-scroll-to="'#prueba'" class="subelementos3" @click="menuClick('android')">Principios</p>

        </div>
</div>

And then in another component:

<div id="prueba">
      <p>TEXTEXT</p>
</div>

I don't know if someone is familiar with this tool. I think i am missing something important.

PS: Maybe is a stupid question(sorry about that) but, do you think is mandatory to use Nuxtjs? On the official page of the tool it is mentioned, but I think is optional https://vue-scrollto.netlify.app/docs/#nuxt-js.

----EDIT----

The HTML, CSS and JS are in the same file, specifically on a .vue file. I think that maybe I have to import an external library into my .vue file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳根太软 2025-02-15 16:39:03

错误表明您尚未注册该指令。

vue-scrollto文档描述设置指令。插件会自动注册引擎盖下的指令,您可以使用 vue.use()

// main.js
import Vue from 'vue'
import VueScrollTo from 'vue-scrollto'

Vue.use(VueScrollTo)

demo

The error indicates that you haven't registered the directive.

The vue-scrollto docs describe how to setup the directive. The plugin automatically registers the directive under the hood, and you can install the plugin in your app's entry point with Vue.use():

// main.js
import Vue from 'vue'
import VueScrollTo from 'vue-scrollto'

Vue.use(VueScrollTo)

demo

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文