gpt4 book ai didi

javascript - 无法在使用 nuxtjs 的模块外部使用 import 语句

转载 作者:行者123 更新时间:2023-12-05 00:34:53 25 4
gpt4 key购买 nike

我正在尝试使用 vue-agile carousel,我可以在安装后立即安装并让它运行而没有任何问题,我正在使用 NUXT,但是在重新启动我的服务器后,我不断收到此错误并且找不到任何解决方案

<template>
<div>
<agile>
<div class="slide">
<img src="/img/img2.jpg" alt="" />
</div>
<div class="slide">
<img src="/img/img1.jpg" alt="" />
</div>
</agile>
</div>
</template>
<script >
import { VueAgile } from "vue-agile";
export default {
name: "",
layout: "",
middleware: [],
data() {
return {};
},
components: {
agile: VueAgile,
},

};
</script>
enter image description here
enter image description here

最佳答案

您是否查看了有关 how to use this plugin in Nuxt 的文档?而不是常规的 Vue?
插件/vue-agile.js

import Vue from 'vue'
import VueAgile from 'vue-agile'

Vue.use(VueAgile)
nuxt.config.js
export default {
plugins: ['~/plugins/vue-agile', mode: 'client']
}
要使用没有 SSR 的组件,请使用 client-only零件:
<client-only placeholder="Loading...">
<agile>...</agile>
</client-only>
编辑 :添加 Shreerang 的建议(下方评论)。

关于javascript - 无法在使用 nuxtjs 的模块外部使用 import 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64132293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com