根据环境有条件地选择一个版本的jquery [英] Conditionally selecting a version of jquery depending on environment

查看:77
本文介绍了根据环境有条件地选择一个版本的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(带补丁)将查找以下文件:

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文件放在

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/ ?"

推荐答案

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆