首页 前端知识 Bootstrap‘s JavaScript requires jQuery in vue 2.5

Bootstrap‘s JavaScript requires jQuery in vue 2.5

2025-03-03 13:03:26 前端知识 前端哥 595 552 我要收藏

题意:Bootstrap的JavaScript在Vue 2.5中需要jQuery

问题背景:

Hello guys im new to vue, I have searched google but haven't found any solution related to my problem. Here is an overview of the problem, I try to create home page in vue and in it are some external scripts. I want this script to be available only for home page.

大家好,我是Vue的新手。我已经搜索过谷歌,但没有找到与我问题相关的任何解决方案。这是问题的概述:我尝试在Vue中创建一个主页,并在其中加入了一些外部脚本。我希望这些脚本仅对主页可用。

<template>
<div class="app">
<HomeHeader />
<div class="app-body">
<main class="main">
<div class="container-fluid">
<router-view></router-view>
</div>
</main>
</div>
<HomeFooter/>
</div>
</template>
<script>
import HomeHeader from '../components/HomeHeader'
import HomeFooter from '../components/HomeFooter'
import jquery from 'jquery';
global.jQuery=jquery;
import bootstrap from '../containers/home/js/bootstrap.min.js';
import popper from '../containers/home/js/popper.min.js';
import revolution from '../containers/home/js/extensions/revolution.extension.slideanims.min.js';
import main from '../containers/home/js/main.js';
import all from '../containers/home/js/all.js';
export default {
name: 'Homepage1',
components: {
HomeHeader,
HomeFooter,jquery,bootstrap,popper,revolution,main,all,
},
}
复制

here is my all script        这是我的脚本

var tpj = jQuery;
var revapi24;
tpj(document).ready(function() {
if (tpj("#rev_slider_main").revolution == undefined) {
revslider_showDoubleJqueryError("#rev_slider_main");
} else {
revapi24 = tpj("#rev_slider_main").show().revolution({
sliderType: "standard",
jsFileLocation: "revolution/js/",
sliderLayout: "fullscreen",
dottedOverlay: "none",
delay: 9000,
navigation: {
keyboardNavigation: "off",
keyboard_direction: "horizontal",
mouseScrollNavigation: "off",
mouseScrollReverse: "default",
onHoverStop: "off",
bullets: {
enable: true,
hide_onmobile: false,
style: "bullet-bar",
hide_onleave: false,
direction: "horizontal",
h_align: "center",
v_align: "bottom",
h_offset: 0,
v_offset: 50,
space: 5,
tmp: ''
}
},
responsiveLevels: [1240, 1024, 778, 480],
visibilityLevels: [1240, 1024, 778, 480],
gridwidth: [1240, 1024, 778, 480],
gridheight: [868, 768, 960, 720],
lazyType: "none",
shadow: 0,
spinner: "off",
stopLoop: "off",
stopAfterLoops: -1,
stopAtSlide: -1,
shuffle: "off",
autoHeight: "off",
fullScreenAutoWidth: "off",
fullScreenAlignForce: "off",
fullScreenOffsetContainer: "",
fullScreenOffset: "60px",
hideThumbsOnMobile: "off",
hideSliderAtLimit: 0,
hideCaptionAtLimit: 0,
hideAllCaptionAtLilmit: 0,
debugMode: false,
fallbacks: {
simplifyAll: "off",
nextSlideOnWindowFocus: "off",
disableFocusListener: false,
}
});
}
if (revapi24) revapi24.revSliderSlicey();
});
复制

Now my problem is that it throws an error in all script that jQuery is not define. Another error is Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript

现在我的问题是,在所有脚本中都抛出了一个错误,提示jQuery未定义。另一个错误是Bootstrap的JavaScript需要jQuery。在引入Bootstrap的JavaScript之前必须先包含jQuery。

问题解决:

You shouldn't use JQuery and Vue in the same project. Personally, I recommend 302 - JS.ORG which is a Vue wrapper for Bootstrap and works fine.

你不应该在同一个项目中使用jQuery和Vue。就我个人而言,我推荐302 - JS.ORG。它是一个为Bootstrap提供的Vue封装,并且工作得很好

转载请注明出处或者链接地址:https://www.qianduange.cn//article/22520.html
标签
评论
还可以输入200
共0条数据,当前/页
发布的文章

如何修改电脑mac地址?

2025-03-03 13:03:33

C 数组:深入解析与应用

2025-03-03 13:03:28

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!