我有一个 patternlab 实现(edition-node-gulp)。我正在尝试将 selectize.js 添加到它(https://github.com/selectize/selectize.js)。当我将指示的 jquery 函数添加到 foot.mustache 文件并检查结果时,控制台指示reference error: can't find variable $
(即无法识别 jquery)。当我将 jquery.min.js 添加到 head.mustache 时,在我的 selectize.js 脚本标记上方,模式实验室的一些功能停止工作,其中一些开始工作,并且我开始收到不同的错误消息(即它现在可以识别 jquery) .TypeError: $('#select-beast').selectize is not a function.
这是head.mustache:
<!DOCTYPE html>
<html class="{{ htmlClass }}">
<head>
<title>{{ title }}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="../../css/style.css?{{ cacheBuster }}" media="all" />
<link rel="stylesheet" href="../../css/pattern-scaffolding.css?{{ cacheBuster }}" media="all" />
<!-- Begin Pattern Lab (Required for Pattern Lab to run properly) -->
{{{ patternLabHead }}}
<!-- End Pattern Lab -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
<script src="../js/selectize.js"></script>
</head>
<body class="{{ bodyClass }} prg">
这是foot.mustache:
<!--DO NOT REMOVE-->
{{{ patternLabFoot }}}
<!--selectize -->
<script type="text/javascript" src="selectize.js"></script>
<link rel="stylesheet" type="text/css" href="selectize.css" />
<script>
$(function() {
$('select').selectize(options);
});
</script>
<!-- end selectize -->
</body>
</html>