亨_文 2021-09-09 16:51 采纳率: 33.3%
浏览 152
已结题

Vue3安装swiper7,安装之后,vue@cli认为swiper不存在

我按照官网上来的,就是这个 Swiper Vue.js Components Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior. https://swiperjs.com/vue

$ npm i swiper                                                              

added 3 packages, and audited 1287 packages in 4s

80 packages are looking for funding
  run `npm fund` for details

10 moderate severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

这是我的代码:

<template>
    <swiper 
        :slides-per-view="3"
        :space-between="50"
        @swiper="onSwiper"
        @slideChange="onSlideChange"
    >
        <swiper-slide>Slide 1</swiper-slide>
        <swiper-slide>Slide 1</swiper-slide>
        <swiper-slide>Slide 1</swiper-slide>
        <swiper-slide>Slide 1</swiper-slide>
    </swiper>
</template>

<script>

import { Swiper, SwiperSlide } from 'swiper/vue'

export default {
    components:{
        Swiper,
        SwiperSlide
    },
    methods:{
        onSwiper:(swiper)=>{
            console.log(swiper)
        },
        onSlideChange:()=>{
            console.log('slide change');
        }
    }
}
</script>

这是报错:

 ERROR  Failed to compile with 1 error                                                    下午4:49:21

This dependency was not found:

* swiper in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/components/FindeSwiper.vue?vue&type=script&lang=js

To install it, you can run: npm install --save swiper
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 9月17日
    • 创建了问题 9月9日

    悬赏问题

    • ¥30 STM32 INMP441无法读取数据
    • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
    • ¥15 用visualstudio2022创建vue项目后无法启动
    • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
    • ¥500 把面具戴到人脸上,请大家贡献智慧
    • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
    • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
    • ¥30 c#打开word开启修订并实时显示批注
    • ¥15 如何解决ldsc的这条报错/index error
    • ¥15 VS2022+WDK驱动开发环境