根据环境有条件地选择一个版本的jquery

根据环境有条件地选择一个版本的jquery

本文介绍了根据环境有条件地选择一个版本的jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的母版页中有2个对jQuery的引用,当前已针对生产版本进行配置:

I have 2 references to jQuery in my master page which is currently configured for production release:

<script type="text/javascript"
 src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">
</script>
<%--<script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>--%>

在进行开发时,我会取消注释vsdoc版本,以便在VS2008中获得智能感知,然后在部署它之前将其切换回-除非我忘记了.有没有一种方法可以在开发人员中拥有intellisense并在产品中使用不需要部署编辑的Google CDN?即依赖于环境的条件包含...

When I'm developing, I uncomment the vsdoc version so that I get intellisense in VS2008 and then switch it back before deploying it - except for the times that I forget. Is there a way to have intellisense in dev and use the Google CDN in prod that doesn't require an edit to deploy? i.e. a conditional inclusion dependent on environment...

如果我指定此文件: http://ajax. googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js 作为我的JavaScript文件,然后VS2008(带补丁)将查找以下文件: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery .min-vsdoc.js (在.js之前带有-vsdoc)用于智能感知.问题是Google不在该位置提供第二个命名文件.

If I specify this file: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js as my JavaScript file then VS2008 (with patch) will look for this file: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min-vsdoc.js (with -vsdoc just before the .js) to use for intellisense. The problem is that Google does not provide the second named file in that location.

另一个可接受的答案是该问题的答案:我如何让Google将jquery.min-vsdoc.js文件放在 http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/吗?"

Another acceptable answer would be the answer to this question: "How do I get Google to put a jquery.min-vsdoc.js file at http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/ ?"

推荐答案

建议的解决方法(因为Google未托管文档)是要以一种永远不会被包含的方式引用文档脚本,例如

The suggested workaround (since Google doesn't host the documentation) is to reference the documentation script in a way that will never be included, for example

<% if (false) { %>
    <script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>
<% } %>

OR

<asp:PlaceHolder runat="server" Visible="False">
    <script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>
</asp:PlaceHolder>

这篇关于根据环境有条件地选择一个版本的jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 17:17