html好看的侧滑效果,H5 - 侧滑效果实现

本文详细介绍了如何使用APICloud实现侧滑界面的打开、关闭及交互功能。通过api.openDrawerLayout和api.openDrawerPane方法可以分别打开侧滑界面和弹出侧滑菜单,而api.closeDrawerPane则用于关闭侧滑菜单。示例代码展示了cehua.html和cehua_right.html两个页面的样式设置和事件处理,包括点击事件和状态栏修复。侧滑界面包含动态加载的数据列表,点击列表项可以改变选中状态并关闭侧滑菜单。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1ff79e02b566

cehua.gif

APICloud 跳到侧滑界面父界面的方法:openDrawerLayout

APICloud 弹出侧滑界面方法: openDrawerPane

APICloud 关闭弹出的侧滑界面: closeDrawerPane

cehua.html 是承载侧滑界面的父页面,cehua_right.html是要弹出的侧滑界面

api.openDrawerLayout({

name: 'cehua',

url: './cehua.html',

animation: {

type: 'push'

},

rightPane: {

name: 'cehua_right',

url: './cehua_right.html',

}

});

cehua.html

侧滑承载界面

.aui-bar{

background: #45C01A;

}

侧滑

apiready = function(){

$api.fixStatusBar($api.byId('header'));

}

function closeWin(){

api.closeWin({

});

}

function clickNavRightItem(){

console.log("点击侧滑按钮");

api.openDrawerPane({

type: 'right'

});

}

cehua_right.html

侧滑

body {

background: #001041;

}

html {

background: #001041;

}

.aui-bar {

background: #001041;

}

.title {

color: white;

font-size: 20px;

}

.cell_BgColor {

background: #001041;

}

.bgCell {

padding-left: 15px;

height: 60px;

line-height: 60px;

vertical-align: middle;

cursor: pointer;

/*border: 1px solid white;*/

}

.line {

border-bottom: 1px solid white;

}

.name {

color: white;

font-size: 18px;

}

.clickSelColor {

color: red;

background: yellow;

}

标题

about_app.png这是标题

{{each }}

{{$value.name}}

{{/each}}

apiready = function() {

$api.fixStatusBar($api.byId('header'));

var ALLData = [{

"id": "1",

"name": "信息1",

}, {

"id": "2",

"name": "信息2",

}, {

"id": "3",

"name": "信息3",

}, {

"id": "4",

"name": "信息4",

}];

let html = template('template', ALLData);

$api.html($api.byId('CellList'), html);

api.parseTapmode();

var items = $api.domAll(".name");

if ($api.hasCls(items[0], 'clickSelColor') == false) {

$api.addCls(items[0], 'clickSelColor');

}

}

function clickItem(id) {

console.log("id---"+id);

var items = $api.domAll(".name");

for (var i = 0; i < items.length; i++) {

if ( $api.hasCls(items[i], 'clickSelColor') ){

$api.removeCls(items[i],'clickSelColor');

}

}

var item= $api.byId(id);

$api.addCls(item,'clickSelColor');

api.closeDrawerPane();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值