当前位置: 首页 > 工具软件 > slidePage > 使用案例 >

关于"Slidepage传值问题"的解决方法

朱博实
2023-12-01

1.问题描述

答:很多人遇到了怎么向slidepage加载的子界面里面传值或者刷新数据的问题,下面的demo也许能提供帮助。

2.主界面代码(加载slidepage界面代码)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hello World
</title>
</head>
<body>
  <nav id="slide_nav" title="SlidePage" enableRight="true" />
  <div width="100%" height="100%">
    <slide id="slide" tipVisible="false">
      <slideurl url="/slidepage1.html" /> 
      <slideurl url="/slidepage2.html" />
      <slideurl url="/slidepage3.html" /> 
    </slide>
  </div>
  <div height="50" width="100%" layout="HBox" >
    <input type="button" value="切换page1" onClick="slideToPage1" />
    <input type="button" value="切换page2" onClick="slideToPage2"/>
    <input type="button" value="切换page3" onClick="slideToPage3"/>
  </div>
  
</body>
<script>
  
  function slideToPage1(){
    slide.setSelectedIndex(0);
    //requestData1();
  }
  
  function slideToPage2(){
    slide.setSelectedIndex(1);
    //requestData2();
  }
  
  function slideToPage3(){
    slide.setSelectedIndex(2);
    //requestData3();
  }
  
  slide.addEvent("onChange",function(oldValue,newValue){
    if(newValue==0){
      requestData1();
    }else if(newValue==1){
      requestData2();
    }else if(newValue==2){
      requestData3();   
    }
  });
  
  //在slide中声明方法,在子slidepage中具体实现
  var requestData1 = function(){};//请求子页面1数据
  var requestData2 = function(){};//请求子页面2数据
  var requestData3 = function(){};//请求子页面3数据
</script>
</html>

3.slidepage1.html界面的代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Hello World</title>
</head>
<body>
  <input type="label" value="子页面1" width="100" />
</body>
<script>
  requestData1 = function(){
    alert("加载子页面1数据");
  };
  
  
  
</script>
</html>

4.slidepage2.html界面的代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Hello World</title>
</head>
<body>
  <input type="label" value="子页面2" width="100" />
</body>
<script> 
  requestData2 = function(){
    alert("加载子页面2数据");
  };
</script>
</html>

5.slidepage3.html界面的代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Hello World</title>
</head>
<body>
  <input type="label" value="子页面3" width="100" />
</body>
<script> 
  requestData3 = function(){
    alert("加载子页面3数据");
  };
</script>
</html>



 类似资料: