alloy-ui 2.0.0 图片轮播

解压alloy-2.0.0文件之后,demos文件夹下有很多事例,build文件夹中为编译后的事例

本案例以图片轮播为案例:

alloy-2.0.0\demos\carousel 文件夹下的index.html为显示页面,查看源码可以找到需要引用的代码,下面为Portlet如何引用

=================================================================

创建一个Portlet,在JSP文件中引入代码:

JSP

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />
<%
	String basePath = renderRequest.getContextPath();
%>

<script type="text/javascript">
	//加载AUI
	AUI().use('node', 'module2', 'module3',function (A) {
	    //将节点内容打印到控制台  
		console.log(A.one("#example").html());
	});

</script>
<html>
	   <h1>AlloyUI - Carousel图片轮播</h1>
    <div id="demo">
        <div style="background: url(<%=basePath%>/assets/article0.png); width: 940px; height: 253px;" class="carousel-item carousel-item-active"></div>
        <div style="background: url(<%=basePath%>/assets/article1.png); width: 940px; height: 253px;" class="carousel-item"></div>
        <div style="background: url(<%=basePath%>/assets/article2.png); width: 940px; height: 253px;" class="carousel-item"></div>
        <div style="background: url(<%=basePath%>/assets/article3.png); width: 940px; height: 253px;" class="carousel-item"></div>
        <div style="background: url(<%=basePath%>/assets/article0.png); width: 940px; height: 253px;" class="carousel-item"></div>
        <div style="background: url(<%=basePath%>/assets/article1.png); width: 940px; height: 253px;" class="carousel-item"></div>
        <div style="background: url(<%=basePath%>/assets/article2.png); width: 940px; height: 253px;" class="carousel-item"></div>
        <div style="background: url(<%=basePath%>/assets/article3.png); width: 940px; height: 253px;" class="carousel-item"></div>
    </div>
    <script>
	    AUI().use('aui-carousel', function(A) {
	        new A.Carousel({
	            intervalTime: 1,//播放频率,越小越快
	            contentBox: '#demo',
	            activeIndex: 0,
	            height: 254,
	            width: 940
	        }).render();
	
	    });
    </script>
</html>


只需要修改路径(通过getContentPath方法获取),不需要源码中的以下引入,因为Liferay中内部已经引入过了

<link rel="stylesheet" href="../../build/aui-css/css/bootstrap.css">
<script src="../../build/aui/aui.js"></script>

----------------------------------------------------------------

Portlet中显示如下:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荒--

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值