Skip to main content
 首页 » 编程设计

terminal之Bower:安装 2 个版本的 jQuery

2024年02月27日50yjmyzz

我如何使用 Bower 安装 2 个版本的 jQuery?我想要 v2.0 以及 1.9.1 来支持浏览器回退

我遇到的问题是,如果您运行 bower install jquery#1.9.1 jquery#2.0.0 第一个版本会被第二个版本覆盖,因为它们是相同的组件

请您参考如下方法:

根据bower docs

Bower offers several ways to install packages:

# Using the dependencies listed in the current directory's bower.json 
bower install 
# Using a local or remote package 
bower install <package> 
# Using a specific version of a package 
bower install <package>#<version> 
# Using a different name and a specific version of a package 
bower install <name>=<package>#<version> 

您可以安装两个不同版本的 jQuery,如下所示:

bower install jquery-legacy=jquery#1.10 jquery-modern=jquery#2 

或者,如果您喜欢在 bower.json 中进行设置

"dependencies": { 
    "jquery-legacy": "jquery#1.10", 
    "jquery-modern": "jquery#2" 
}