首先在html中的写法是

<ion-header>
<ion-navbar>
<ion-title>历史数据</ion-title>
</ion-navbar>
</ion-header>
<ion-content >
<div style="display:flex;width:625px;">
 
<div class="head">地区</div>
<div style="overflow: hidden;white-space: nowrap;width:250px;height: 50px;" >
<ion-scroll #scroll1 scrollX="true" overflow-scroll="true" has-bouncing="false" (onScroll)="addScrollEventListener()" style="margin-top:0;height:50px">
<div style="display:flex;width:500px;height:50px" id="right">
<div class="head" >到件量</div>
<div class="head">出仓量</div>
<div class="head">滞留量</div>
<div class="head" style="border-right:0;">未派送量</div>
</div>
</ion-scroll>
</div>
 
</div>
<div style="display:flex;width:625px;height: 650px;white-space: nowrap;" >
<ion-scroll #scroll2   scrollY="true" overflow-scroll="true" has-bouncing="false" style="height:550px;width: 125px">
<div *ngFor="let d of data" class="head" >
{{d.zoneName}}
</div>
</ion-scroll>
<div style="overflow: hidden;white-space: nowrap;width:250px">
<ion-scroll direction="xy" #scroll3 scrollX="true" scrollY="true" overflow-scroll="false" has-bouncing="false" delegate-handle="rightContainerHandle" style="height:550px;">
<div style="width:500px;" >
<div *ngFor="let d of data" style="display:flex;" >
<div class="head" >
{{d.arriveTickets}}
</div>
<div class="head">
{{d.moniOutCnt}}
</div>
<div class="head">
{{d.moniStayCnt}}
</div>
<div class="head" style="border-right:0;">
{{d.moniUndeliveryCnt}}
</div>
</div>
</div>
</ion-scroll>
</div>
</div>
</ion-content>
标红颜色的首先是在ts中滚动时需要用到的变量,是个标识符。这个问题我纠结了两天才搞出来。一定记得滚动的监听事件不是on-scroll了
 
 

ts中的代码

import { Component, SystemJsNgModuleLoader,HostListener,NgZone ,ViewChild } from '@angular/core';
import { NavController, NavParams,IonicPageModule} from 'ionic-angular';
import{RestProvider} from '../../providers/rest/rest';
import {Http,Response, Jsonp} from '@angular/http';
import { IonicModule } from 'ionic-angular';
import { NgModule, ErrorHandler ,CUSTOM_ELEMENTS_SCHEMA, SchemaMetadata} from '@angular/core';
import { Directive, ElementRef, Output,Input, EventEmitter } from '@angular/core';
import { ScrollEventModule,ScrollEvent } from 'ngx-scroll-event';
import {Content,Scroll,Spinner} from 'ionic-angular'
import { asElementData } from '@angular/core/src/view';
/**
* Generated class for the AlarmPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@Component({
selector: 'page-rank',
templateUrl: 'rank.html',
})
@NgModule({
imports: [IonicModule,IonicPageModule,ScrollEventModule]
})
export class RankPage {
@Output() scrollChange = new EventEmitter<number>();
@ViewChild(Spinner) spinnerElement: Spinner;
@ViewChild(Content) content: Content;
@ViewChild('scroll3') scroll3: Scroll;
@ViewChild('scroll1') scroll1: Scroll;
@ViewChild('scroll2') scroll2: Scroll;
 
//括号中的值在html页面中标注的时候,名称不能其他属性相同。如该文件已经有一个pnavs的变量,则会报错。
 
addScrollEventListener() {
this.scroll2._scrollContent.nativeElement.onscroll = event => {
this.scroll3._scrollContent.nativeElement.scrollTop =this.scroll2._scrollContent.nativeElement.scrollTop;
// this.scroll1._scrollContent.nativeElement.scrollLeft =this.scroll2._scrollContent.nativeElement.scrollLeft;
}
this.scroll1._scrollContent.nativeElement.onscroll = event => {
//this.scroll3._scrollContent.nativeElement.scrollTop =this.scroll2._scrollContent.nativeElement.scrollTop;
this.scroll3._scrollContent.nativeElement.scrollLeft =this.scroll1._scrollContent.nativeElement.scrollLeft;
}
this.scroll3._scrollContent.nativeElement.onscroll = event => {
this.scroll2._scrollContent.nativeElement.scrollTop =this.scroll3._scrollContent.nativeElement.scrollTop;
this.scroll1._scrollContent.nativeElement.scrollLeft =this.scroll3._scrollContent.nativeElement.scrollLeft;
}
}
ionViewDidLoad() {
this.addScrollEventListener();
}
data=[
{'zoneName':'广州区','arriveTickets':'6987','moniOutCnt':'2221','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'深圳区','arriveTickets':'2356','moniOutCnt':'331','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'武汉区','arriveTickets':'6744','moniOutCnt':'2621','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'苏州区','arriveTickets':'6542','moniOutCnt':'2881','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'杭州区','arriveTickets':'2367','moniOutCnt':'5621','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'东莞区','arriveTickets':'1129','moniOutCnt':'1221','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'惠州区','arriveTickets':'7893','moniOutCnt':'4521','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'汕头区','arriveTickets':'2356','moniOutCnt':'7821','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'清远区','arriveTickets':'67554','moniOutCnt':'9921','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'长沙区','arriveTickets':'5534','moniOutCnt':'2221','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'岳阳区','arriveTickets':'6643','moniOutCnt':'2221','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'株洲区','arriveTickets':'6546','moniOutCnt':'2221','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'南充区','arriveTickets':'4353','moniOutCnt':'2221','moniStayCnt':'45','moniUndeliveryCnt':'44'},
{'zoneName':'鞍山区','arriveTickets':'4526','moniOutCnt':'2221','moniStayCnt':'45','moniUndeliveryCnt':'44'}
];
city=["杭州","郑州","上海","广州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州","杭州",];
stylefor=["含氮量","含磷量","含钾量","含氮量","含磷量","含钾量","含氮量","含磷量","含钾量","含氮量","含磷量","含钾量","含氮量","含磷量","含钾量","含氮量","含磷量","含钾量",];
d=[1,2,3,4,5,6,7,8,9];
list=[];
public items:any=[];
constructor(public navCtrl: NavController,public rest:RestProvider,public jsonp:Jsonp,public http:Http,public zone: NgZone,private el: ElementRef) {//首次打开要显示的数据
 
this.geturl();
}
geturl(){
//console.log(this.getData("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=2&callback=JSONP_CALLBACK"));
//var list=this.getData("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=2&callback=JSONP_CALLBACK");
this.jsonp.get("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=2&callback=JSONP_CALLBACK").subscribe(function(data){
console.log(data["_body"]);
});
this.http.get("http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=2").subscribe(function(data){
console.log(JSON.parse(data["_body"]));
});
}
public getData(url:string):any{
var rs=this.list;
this.jsonp.get(url).subscribe(function(data){
console.log(data["_body"]["result"]);
var resData:any[]=data["_body"]["result"];
for(var i=0;i<resData.length;i++){
rs.push(resData[i])
}
},function(err){
console.log(err)
})
 
return this.list;
 
}
 
}
 
 
ts中标红的代码是前面html标红的相呼应,然后addScrollEventListener进行滚动的监听 注意:  ionViewDidLoad()这个是ionic3本身的方法,只要触动页面,就能调用这个方法,无论点击还是拉动。
 
然后就是

this.scroll2._scrollContent.nativeElement.onscroll = event => {
this.scroll3._scrollContent.nativeElement.scrollTop =this.scroll2._scrollContent.nativeElement.scrollTop;
// this.scroll1._scrollContent.nativeElement.scrollLeft =this.scroll2._scrollContent.nativeElement.scrollLeft;
}就是监听事件,只要滑动就能触发的事件
 
 
 
 
 
 
 
 

css代码

*{

margin:0px;

padding:0px;

}

.focus{

height: 150px;

width: 100%;

ion-slide{

height: 150px;

width: 100%;

img{

height: 150px;

width: 100%;

}

}

}

.slide_product{

//滚动

ion-scroll{

width:100%;

height:800px;

}

ul{

list-style: none;

padding: 0px 5px;

li{

width: 80px;

height: 120px;

float: left;

margin-right: 10px;

p{

padding:4px;

margin:0px;

}

}

}

}

.home_title{

height: 50px;

width: 100%;

background-image: url("../../assets/imgs/pict1.jpg");

}

.home_title{

height: 50px;

}

.cate_content{

width:100%;

height: 100%; /*首先看高度100% 是否管用 如果没有作用我们要给元素设置绝对定位*/

display: flex;

.cate_left{

width: 100px;

height: 100%;

overflow-y: auto;

}

.cate_right{

height: 100%;

flex:1;

margin-left:5px;

overflow-y: auto;

}

}

table.gridtable {

font-family: verdana,arial,sans-serif;

font-size:11px;

color:#333333;

border-width: 1px;

border-color: #666666;

border-collapse: collapse;

}

table.gridtable th {

border-width: 1px;

padding: 8px;

width:2%;

border-style: solid;

border-color: #666666;

background-color: #dedede;

}

table.gridtable td {

border-width: 1px;

padding: 8px;

width:2%;

border-style: solid;

border-color: #666666;

background-color: #ffffff;

color: #f53d3d;

}

.head{

border-bottom:solid 1px #D1D3D6;

border-right:solid 1px #D1D3D6;

height:50px;

display:flex;

align-items:center;

width:125px;

font-size:14px;

color:#262626;

justify-content:center;

}

代码效果图如下

2018-08-17

利用ionic3进行上一行和左一行不动,中间移动的功能的更多相关文章

  1. 【零碎小bug系列】windows下的回车和换行符,cmd(telnet)上输出不左对齐

    cmd(telnet)上输出不左对齐,而是有莫名其妙的空格 目录 cmd(telnet)上输出不左对齐,而是有莫名其妙的空格 背景 解决 细究 背景 在cmd上使用telnet连接本地端口的服务器时, ...

  2. App上架流程[利用Archive进行上传]

    作者 M_Lee2016.01.22 10:47 写了14852字,被32人关注,获得了49个喜欢 [iOS]App上架流程[利用Archive进行上传] 字数2186 阅读507 评论3 喜欢9 今 ...

  3. 【ARM-LInux开发】利用scp 远程上传下载文件/文件夹

    利用scp 远程上传下载文件/文件夹 scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o s ...

  4. sed在文本第一行和最后一行添加字符串

    shell在文本第一行和最后一行添加字符串 sed -i '1 i\ApiInterfaceName ResposeTime' /tmp/apiLog/apiLogFromatSecond.logse ...

  5. 利用 FormData 对象和 Spring MVC 配合可以实现Ajax文件上载功能

    Ajax文件上载 利用 FormData 对象和 Spring MVC 配合可以实现Ajax文件上载功能: 步骤 导入组件并准备静态脚本 <dependency> <groupId& ...

  6. Android Camera开发系列(上)——Camera的基本调用与实现拍照功能以及获取拍照图片加载大图片

    Android Camera开发系列(上)--Camera的基本调用与实现拍照功能以及获取拍照图片加载大图片 最近也是在搞个破相机,兼容性那叫一个不忍直视啊,于是自己翻阅了一些基本的资料,自己实现了一 ...

  7. js进阶 12-17 jquery实现鼠标左键按下拖拽功能

    js进阶 12-17 jquery实现鼠标左键按下拖拽功能 一.总结 一句话总结:监听的对象必须是文档,鼠标按下运行mousemove事件,鼠标松开取消mousemove事件的绑定,div的偏移的话是 ...

  8. (Demo分享)利用JavaScript(JS)做一个可输入分钟的倒计时钟功能

    利用JavaScript(JS)实现一个可输入分钟的倒计时钟功能本文章为 Tz张无忌 原创文章,转载请注明来源,谢谢合作! 网络各种利用JavaScript做倒计时的Demo对新手很不友好,这里我亲手 ...

  9. 利用WebRequest类上传文件

    说明:1.WebRequest类是一个抽象类,所以上传类实际使用的是其子类 2.打开Fiddler软件,监视正常网页的文件上传,可以看到http协议的请求和响应信息,简略说明 (第一行:请求说明 PO ...

随机推荐

  1. JUnit 5和Selenium基础(一)

    Gradle.JUnit 5和Jupiter Selenium Selenium是一组支持浏览器自动化的工具,主要用于Web应用程序测试.Selenium的组件之一是Selenium WebDrive ...

  2. 【转】15个超炫的HTML5效果

    英文原文:http://www.hongkiat.com/blog/15-html5-experiments/     翻译:iteye 乔布斯没有给Flash任何机会,微软新推出的Windows 8 ...

  3. 【转】.NET 在云原生时代的蜕变,让我在云时代脱颖而出

    原创:张善友 原文:https://www.cnblogs.com/shanyou/p/12198741.html .NET 生态系统是一个不断变化的生态圈,我相信它正在朝着一个伟大的方向发展.有了开 ...

  4. 软件工程概论 网站开发要掌握的技术 &登录界面

    1.网站系统开发需要掌握的技术 一.界面和用户体验(Interface and User Experience) 1.1 知道如何在基本不影响用户使用的情况下升级网站.通常来说,你必须有版本控制系统( ...

  5. 小白学Java:File类

    目录 小白学Java:File类 不同风格的分隔符 绝对与相对路径 File类常用方法 常用构造器 创建方法 判断方法 获取方法 命名方法 删除方法 小白学Java:File类 我们可以知道,存储在程 ...

  6. JavaScript中this的使用及含义(总结)

    this 1.谁调用,指向谁 2.事件监听函数中,this指向,绑定监听函数的那一个元素节点 即,谁绑,指向谁 3.当一个函数没有被其他对象调用时,(普通调用),this指向全局对象(严格模式下面是u ...

  7. Python中__init__的用法和理解

    在Python中定义类经常会用到__init__函数(方法),首先需要理解的是,两个下划线开头的函数是声明该属性为私有,不能在类的外部被使用或访问.而__init__函数(方法)支持带参数类的初始化, ...

  8. Linux文件内容重定向

    文件描述符 可以理解为linux跟踪打开文件,而分配的一个数字,这个数字有点类似c语言操作文件时候的句柄,通过句柄就可以实现文件的读写操作. 用户可以自定义文件描述符范围是:3-num,这个最大数字, ...

  9. oracle问题之数据库恢复(三)

    可能很多人在做数据库恢复时,都遇到过如下错误: SQL> recover database; ORA: recovery session canceled due to errors ORA: ...

  10. Docker深入浅出系列 | 单节点多容器网络通信

    目录 教程目标 准备工作 带着问题开车 同一主机两个容器如何相互通信? 怎么从服务器外访问容器 Docker的三种网络模式是什么 Docker网络通信原理 计算机网络模型回顾 Linux中的网卡 查看 ...