我们在做APP的时候,很多时候会有这样的功能需求,例如:登录,充值,如果登录成功,或充值成功后,需要更改当前页面以及父页面的状态信息,就会用到在子页面调用父页面的方法来实现:在子页面刷新父页面的功能。

不多说:看代码

父页面:b.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title></title>
<link rel="stylesheet" type="text/css" href="../css/mui.min.css">
<style type="text/css">
*{margin:0px; padding:0px;}
div.main{width: 100%; position: absolute; top:0px; right:0px; bottom:0px; left:0px; background:#eee;}
div.main-scroll{width: 100%; position: absolute; top:0px; right:0px; bottom:0px; left:0px; overflow: scroll;}
ul.list{width: 100%;}
ul.list li{width: 100%; line-height: 40px; padding-left: 10px;}
</style>
</head>
<body>
<div class="main" id="main">
<div class="main-scroll">
<h3>{{message}}</h3>
<button @tap="bbbb">改变</button>
<ul class="list">
<li @tap="details">我是新闻动态</li>
<li @tap="details">我是新闻动态</li>
<li @tap="details">我是新闻动态</li>
<li @tap="details">我是新闻动态</li>
<li @tap="details">我是新闻动态</li>
<li @tap="details">我是新闻动态</li>
<li @tap="details">我是新闻动态</li>
</ul>
</div>
</div>
</body>
<script type="text/javascript" src="../js/vue.min.js"></script>
<script type="text/javascript" src="../js/mui.min.js"></script>
<script type="text/javascript">
function aaaa(){
console.log("我是 aaaa 方法");
};
var main = new Vue({
el: "#main",
data: {
message:'我是b.html页面',
list:[],
},
mounted: function(){
},
watch: {},
methods: {
bbbb:function(){
console.log("我是 bbbb 方法");
this.message = "你真的是b.html页面吗?";
},
cccc:function(){
console.log("我是 ccc 方法");
},
details:function(){
mui.openWindow({
url:'./b-details.html',
id:'b.html',
createNew:true,
styles:{top:'0px',bottom:'0px'},
show:{autoShow:true,aniShow:'slide-in-bottom',duration:260},
waiting:{autoShow:false,title:'',options:{}}
});
},
}
}); </script>
</html>

子页面:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Document</title>
<link rel="stylesheet" type="text/css" href="../css/mui.css">
<style type="text/css">
div.main{width: 100%; position: absolute; top:0px; right:0px; bottom:0px; left:0px; background:#eee;}
div.main-scroll{width: 100%; position: absolute; top:0px; right:0px; bottom:0px; left:0px; overflow: scroll; background:orange;}
</style>
</head>
<body>
<div class="main" id="main">
<div class="main-scroll">
<button class="mui-action-back">点击返回</button>
<div>我是新闻动态的详情</div>
<button class="mui-button" @tap="bbbbfun">我是新闻动态</button>
</div>
</div>
<script type="text/javascript" src="../js/vue.min.js"></script>
<script type="text/javascript" src="../js/mui.min.js"></script>
<script type="text/javascript">
var main = new Vue({
el: "#main",
data: {
list:[],
selfWindow:null,
opener:null,
},
mounted: function(){
mui.plusReady(()=>{
// this.plus = plus;
// var selfWindow = plus.webview.currentWebview();
// var opener = selfWindow.opener();
// opener.evalJS('aaaa()');
// opener.evalJS('main.bbbb()');
// opener.evalJS('main.cccc()');
this.selfWindow = plus.webview.currentWebview();
this.opener = this.selfWindow.opener();
this.opener.evalJS('aaaa()');
this.opener.evalJS('main.bbbb()');
this.opener.evalJS('main.cccc()');
});
},
watch: {},
methods: {
// 主动调用父页面的方法
bbbbfun:function(){
this.opener.evalJS('main.bbbb()');
},
}
});
</script>
</body>
</html>

mui---子页面主动调用父页面的方法的更多相关文章

  1. vue:子组件通过调用父组件的方法的方式传参

    在本案例中,由于子组件通过调用父组件的方法的方式传参,从而实现修改父组件data中的对象,所以需要啊使用$forceUpdate()进行强制刷新 父组件: provide() { return { s ...

  2. uni-app 子组件如何调用父组件的方法

    1.在父组件methods中定义一个方法: changeType:function(type){ this.typeActive = type; alert(type); } 2.在父组件引用子组件时 ...

  3. layer.open打开iframe页面的调用父页面方法及关闭

    //调用父类方法 window.parent.exportData($('#shownum').val(),$('#splitstr').val()); //关闭iframe页面var index = ...

  4. 【转】C# 子窗体如何调用父窗体的方法

    网络上有几种方法,先总结如下: 调用窗体(父):FormFather,被调用窗体(子):FormSub. 方法1: 所有权法       //FormFather:        //需要有一个公共的 ...

  5. 使用iframe父页面调用子页面和子页面调用父页面的元素与方法

    在实际的项目开发中,iframe框架经常使用,主要用于引入其他的页面.下面主要介绍一下使用iframe引入其他页面后,父页面如何调用子页面的方法和元素以及子页面如何调用父页面的方法和元素. 1.父页面 ...

  6. JS 在open打开的子窗口页面中调用父窗口页面的JS方法

    需求的情景如下: 1:做新增或修改等操作的时候打开一个新的浏览器窗口(使用window.open(参数等)方法) 2:在新增或修改等的页面上有返回按钮.重置按钮.保存按钮,对于返回就直接关闭此窗口(使 ...

  7. 实现 iframe 子页面调用父页面中的js方法

    父页面:index.html(使用iframe包含子页面child.html) [xhtml] view plaincopyprint? <html> <head> <s ...

  8. iframe子页面调用父页面javascript函数的方法

    1.iframe子页面调用 父页面js函数 子页面调用父页面函数只需要写上window.parent就可以了.比如调用a()函数,就写成: window.parent.a(); 2.iframe父页面 ...

  9. easyUi弹出window窗口传值与调用父页面的方法,子页面给父页面赋值

    <!-- 父页面 --> <!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" "ht ...

随机推荐

  1. qt不能调试

    在F5执行qt的调试时,提示:unknown debugger type "No engine" 需要下载debug调试工具,win7的下载位于:https://www.micro ...

  2. Android进程命令查看

    •       进程 是指一个具有独立功能的程序在某个数据集上的一次动态运行过程,它是系统进行资源分配和调度的最小单元. •       一个进程能够拥有多个线程.每一个线程必须有一个父进程. •   ...

  3. NuGet Package Explorer

    https://www.microsoft.com/zh-cn/store/p/nuget-package-explorer/9wzdncrdmdm3?ocid=badge&rtc=1

  4. spring cloud配置中心属性加密处理

    在现实的场景里,我们会在配置中心配置很多中间件的账号密码(通常都是读写账号),如果采用明文存储将会有很大的风险导致账号泄露,解决方案: http://blog.didispace.com/spring ...

  5. testng.xml 配置大全

    1.TestNG的运行方式如下: 1 With a testng.xml file 直接run as test suite 2 With ant 使用ant 3 From the command li ...

  6. 简单的redis测试

    //这个方法会多一次 public function testRedisList(){ $num = 10; $user_id = uniqid(); //直接链接本地的redis $redis = ...

  7. Java对象的内存实际占用

    一.打包和使用方法参考我之前的这篇文章,本文主要是更新了测量的类及方法,实际测试这个方法更准确. https://www.cnblogs.com/yoyotl/p/8421287.html 二.新的测 ...

  8. MVC 打印解决方案--SNF快速开发平台3.1

    SNF-MVC打印报表方案: 报表模块创建的过程如下: 利用Stimulsoft Reports客户端报表工具新增一个报表文件 *.mrt 当然你也可以拿好用的*.mrt模版文件进行复制出来一个,我常 ...

  9. 物联网架构成长之路(13)-SpringBoot入门

    1. 前言 下载最新版的JavaEE eclipse-jee-oxygen-2-win32-x86_64.zip 安装STS插件 Window->Eclipse Marketplace -> ...

  10. Socket网络编程--简单Web服务器(4)

    上一小节已经实现了对图片的传输,接下来就是判断文件是否为js,css,png等格式.我们增加一个函数用于判断格式 int WebServer::get_filetype(char *type,char ...