0
我想在我的Angular 2应用程序中使用fancybox
包。我使用npm
安装了这个软件包,并且仔细阅读了文档。但fancybox
不起作用。起初我认为这个问题是href的,比如http://localhost8000/media...
所以我决定使用fancybox包中的简单图片进行测试。但它也没有工作,它只是在图像的url的下一个选项卡中打开图像。Fancybox in Angular 2
的index.html:
<html>
<head>
<base href="/">
<title>PhotoHub</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% load staticfiles %}
<link rel="stylesheet" href="{% static "node_modules/bootstrap/dist/css/bootstrap.min.css" %}">
<link href="{% static "bower_components/font-awesome/css/font-awesome.min.css" %}" rel="stylesheet" />
<link href="{% static "bower_components/alertify.js/themes/alertify.core.css" %}" rel="stylesheet" />
<link href="{% static "bower_components/alertify.js/themes/alertify.bootstrap.css" %}" rel="stylesheet" />
<link href="{% static "node_modules/fancybox/dist/css/jquery.fancybox.css" %}" type="text/css" media="screen"/>
<link rel="stylesheet" href="{% static "styles.css" %}">
<script src="{% static "bower_components/jquery/dist/jquery.min.js" %}"></script>
<script src="{% static "node_modules/bootstrap/dist/js/bootstrap.min.js" %}"></script>
<script src="{% static "bower_components/alertify.js/lib/alertify.min.js" %}"></script>
<script src="{% static "node_modules/fancybox/dist/js/jquery.fancybox.pack.js" %}"></script>
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="{% static "node_modules/core-js/client/shim.min.js" %}"></script>
<script src="{% static "node_modules/zone.js/dist/zone.js" %}"></script>
<script src="{% static "node_modules/reflect-metadata/Reflect.js" %}"></script>
<script src="{% static "node_modules/systemjs/dist/system.src.js" %}"></script>
<!-- 2. Configure SystemJS -->
<script src="{% static "systemjs.config.js" %}"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
$(document).ready(function() {
$(".fancybox").fancybox({type: "image"});
console.log('fancybox image')
});
</script>
</head>
<!-- 3. Display the application -->
<body>
<photohub></photohub>
</body>
</html>
我试图用的fancybox:
<a data-fancybox-type="image" class="fancybox" rel="group" href="static\node_modules\fancybox\demo\1_b.jpg"><img src="static\node_modules\fancybox\demo\1_b.jpg" alt="" /></a>