所以我看到了其他問題與這個相同的標題,我不認爲我遇到了他們有相同的問題(具體是因爲我我沒有使用Drupal,並且這些文件似乎正在加載頁面標題中,如下所示)。我明白它找不到那個功能,但我不知道爲什麼。這是theme.liquid頭裏面的代碼在那裏建立了JavaScript和樣式:
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="canonical" href="{{ canonical_url }}" />
{% assign maxmeta = 155 %}
{% if template contains 'product' %}
<meta name="description" content="{{ product.description | strip_html | strip_newlines | truncate: maxmeta | escape }}" />
{% elsif template contains 'page' %}
<meta name="description" content="{{ page.content | strip_html | strip_newlines | truncate: maxmeta | escape }}" />
{% elsif template == 'index' and shop.description != '' %}
<meta name="description" content="{{ shop.description }}" />
{% endif %}
{{ 'skinCustom.css' | asset_url | stylesheet_tag }}
{{ 'jquery-1.4.2.min.js' | asset_url | script_tag }}
{{ 'jquery.jcarousel.min.js' | asset_url | script_tag }}
{% if template == 'index' %}
<title>{{ shop.name }}</title>
{% elsif template == '404' %}
<title>Page Not Found | {{ shop.name }}</title>
{% else %}
<title>{{ page_title }} | {{ shop.name }}</title>
{% endif %}
{% include 'fb-open-graph' %}
{% case settings.header_font %}
{% when "Rancho, cursive" %}
<link href='http://fonts.googleapis.com/css?family=Rancho' rel='stylesheet' type='text/css'>
{% when "'Amatic SC', cursive" %}
<link href='http://fonts.googleapis.com/css?family=Amatic+SC:700' rel='stylesheet' type='text/css'>
{% when "'Sancreek', cursive" %}
<link href='http://fonts.googleapis.com/css?family=Sancreek' rel='stylesheet' type='text/css'>
{% when "'Ubuntu Condensed', sans-serif" %}
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Condensed' rel='stylesheet' type='text/css'>
{% endcase %}
{{ 'style.css' | asset_url | stylesheet_tag }}{% if template contains 'product' and settings.main_image_display == 'Lightbox' %}
{{ 'jquery.fancybox-1.3.4.css' | asset_url | stylesheet_tag }}{% endif %}
{{ 'modernizr.js' | asset_url | script_tag }}
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
{% if template contains 'customers' %}
{{ "shopify_common.js" | shopify_asset_url | script_tag }}
{{ "customer_area.js" | shopify_asset_url | script_tag }}
{% endif %}
<script type="text/javascript">
$(document).ready(function() {
$('#mycarousel').jcarousel({ vertical: true, scroll: 1, start: 3 });
});
</script>
{{ '//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js' | script_tag }}
{{ content_for_header }}
當頁面渲染我碰到下面的(我編輯了多餘的東西不屬於這個問題)。我把箭頭指向jcarousel依賴的js和樣式頁面的引用。在我試圖將其移植到Shopify項目之前,我在一個單獨的文件中有一個這樣的例子。
<head>
<meta charset="UTF-8">
--> <link href="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/skinCustom.css?241" rel="stylesheet" type="text/css" media="all" />
--> <script src="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/jquery-1.4.2.min.js?241" type="text/javascript"></script>
--> <script src="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/jquery.jcarousel.min.js?241" type="text/javascript"></script>
<link href="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/style.css?241" rel="stylesheet" type="text/css" media="all" />
<script src="http://cdn.shopify.com/s/files/1/0212/5406/t/1/assets/modernizr.js?241" type="text/javascript"></script>
<script src="http://cdn.shopify.com/s/shopify/option_selection.js?aaf2a68ed9671e345bbc7eef1e63563c51bde6eb" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
ERROR HERE --> $('#mycarousel').jcarousel({ vertical: true, scroll: 1, start: 3 });
});
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="/global/theme-controls.css" type="text/css" />
</head>
我可以想象的唯一可能的事情就是其中一個腳本文件正在搞砸了。但我不確定除了取出其他腳本文件之外,我將如何進行調試。如果有人遇到類似的問題或對此有所瞭解,我將不勝感激。除了錯誤的執行之外,其他問題似乎都沒有得到答案(就像將腳本從頭開始)。我可能會做些愚蠢的事情,但我已經研究過這無數次,我看不到它是什麼。
感謝,
艾倫
爲什麼要加載jquery兩次?一個可能的問題是jQuery使用美元符號。嘗試用'jQuery'替換它,以便使用'jQuery('#mycarousel')'或嘗試使用jquery的noconflict模式。 http://api.jquery.com/jQuery.noConflict/ – Stuart 2013-02-13 01:47:52
我看了很多遍......猜想我需要第二雙眼睛。問題就在於,加載jquery兩次是搞砸了。我這樣做是因爲當我最初嘗試使用jcarousel時,它說它找不到它所依賴的jquery。所以我自己添加了它,只是假設它尚未加載它。感謝您的迴應。我一直試圖弄清楚這幾個小時。 – 2013-02-13 01:59:57
如果所有訂單都正確並且沒有衝突,會發生什麼情況。並且它仍然沒有被識別(但是你可以在控制檯中看到它被加載了) – 2016-12-30 09:03:32