未捕获的引用错误 YUI 未定义控制台错误
uncaught Reference error YUI is not defined console error
我在前端使用 alloyui,当我尝试使用这个时出现 issue.uncaught 引用错误 YUI 未定义控制台错误。下面是代码
任何帮助。我刚刚更新了这段代码,请看下面的代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{% block stylesheets %}
<link href="http://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
<script>
YUI().use(
'node',
'transition',
function (Y) {
Y.one('.navbar-brand').on(
'click', function() {
this.transition(
{
width: '500px'
}
);
}
);
}
);
</script>
</head>
<body>
{% block body %}
<div class="container-fluid">
<nav class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="{{ path('dashboard.index') }}">NewsDriver</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="{{ path('dashboard.index') }}">Dashboard</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
<li><a href="#">{{ app.user.getName() }}</a></li>
<li><a href="/logout"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
{% else %}
<li><a href="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
{% endif %}
</ul>
</nav>
{% for flashType, flashMessages in app.session.flashbag.all() %}
{% for flashMessage in flashMessages %}
<div class="alert alert-{{ flashType }}">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ flashMessage }}
</div>
{% endfor %}
{% endfor %}
{% block content %}{% endblock %}
</div>
{% endblock %}
{% block javascripts %}
<script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
{% endblock %}
</body>
</html>
您必须在您呼叫 YUI()
的 <script>
之前放置 <script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
。
您需要先加载 aui-min.js
脚本,然后再 运行 您的自定义 JS 代码。
查看下面编辑的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{% block stylesheets %}
<link href="http://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
{% block body %}
<div class="container-fluid">
<nav class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="{{ path('dashboard.index') }}">NewsDriver</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="{{ path('dashboard.index') }}">Dashboard</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
<li><a href="#">{{ app.user.getName() }}</a></li>
<li><a href="/logout"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
{% else %}
<li><a href="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
{% endif %}
</ul>
</nav>
{% for flashType, flashMessages in app.session.flashbag.all() %}
{% for flashMessage in flashMessages %}
<div class="alert alert-{{ flashType }}">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ flashMessage }}
</div>
{% endfor %}
{% endfor %}
{% block content %}{% endblock %}
</div>
{% endblock %}
{% block javascripts %}
<script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
{% endblock %}
<script>
YUI().use(
'node',
'transition',
function (Y) {
Y.one('.navbar-brand').on(
'click', function() {
this.transition(
{
width: '500px'
}
);
}
);
}
);
</script>
</body>
</html>
我在前端使用 alloyui,当我尝试使用这个时出现 issue.uncaught 引用错误 YUI 未定义控制台错误。下面是代码 任何帮助。我刚刚更新了这段代码,请看下面的代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{% block stylesheets %}
<link href="http://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
<script>
YUI().use(
'node',
'transition',
function (Y) {
Y.one('.navbar-brand').on(
'click', function() {
this.transition(
{
width: '500px'
}
);
}
);
}
);
</script>
</head>
<body>
{% block body %}
<div class="container-fluid">
<nav class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="{{ path('dashboard.index') }}">NewsDriver</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="{{ path('dashboard.index') }}">Dashboard</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
<li><a href="#">{{ app.user.getName() }}</a></li>
<li><a href="/logout"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
{% else %}
<li><a href="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
{% endif %}
</ul>
</nav>
{% for flashType, flashMessages in app.session.flashbag.all() %}
{% for flashMessage in flashMessages %}
<div class="alert alert-{{ flashType }}">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ flashMessage }}
</div>
{% endfor %}
{% endfor %}
{% block content %}{% endblock %}
</div>
{% endblock %}
{% block javascripts %}
<script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
{% endblock %}
</body>
</html>
您必须在您呼叫 YUI()
的 <script>
之前放置 <script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
。
您需要先加载 aui-min.js
脚本,然后再 运行 您的自定义 JS 代码。
查看下面编辑的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{% block stylesheets %}
<link href="http://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
{% block body %}
<div class="container-fluid">
<nav class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="{{ path('dashboard.index') }}">NewsDriver</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="{{ path('dashboard.index') }}">Dashboard</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
<li><a href="#">{{ app.user.getName() }}</a></li>
<li><a href="/logout"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
{% else %}
<li><a href="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
{% endif %}
</ul>
</nav>
{% for flashType, flashMessages in app.session.flashbag.all() %}
{% for flashMessage in flashMessages %}
<div class="alert alert-{{ flashType }}">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ flashMessage }}
</div>
{% endfor %}
{% endfor %}
{% block content %}{% endblock %}
</div>
{% endblock %}
{% block javascripts %}
<script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
{% endblock %}
<script>
YUI().use(
'node',
'transition',
function (Y) {
Y.one('.navbar-brand').on(
'click', function() {
this.transition(
{
width: '500px'
}
);
}
);
}
);
</script>
</body>
</html>