# event
event
模块可以让JSNative打开native原生页面或者JSNative页面。
# 注意事项
LightJSBridge
模块目前只在我们JSNative app端支持,web端不支持
# 示例
<template>
<div>
<text class="button" @click="openWeb()">openWeb</text>
<text class="button" @click="openNative()">openNative</text>
<text class="button" @click="openUrl()">openUrl</text>
</div>
</template>
<style>
.button {
color: #fff;
background-color: #337ab7;
border-color: #2e6da4;
border-radius: 12px;
padding-top: 20px;
padding-left: 36px;
padding-bottom: 20px;
padding-right: 36px;
font-size: 36px;
text-align: center;
font-weight: 500;
margin-bottom: 10px;
}
</style>
<script>
var event = Light.requireModule('event');
var header = Light.requireModule('head');
module.exports = {
created:function(){
header.setTitle({title:"event模块"});
},
methods:{
openWeb:function(action){
event.openNative("web",{startPage:"https://www.baidu.com"});
},
openNative:function(action){
event.openNative("mystock");
},
openUrl:function(){
var item={};
item.prod_code="600570";
item.hq_type_code="XSHG.ESA.M";
item.prod_name="恒生电子";
event.openURL("https://www.lightyy.com/apps/weex-test/navigator.js?stockCode=" + item.prod_code + "&codeType=" + item.hq_type_code + "&stockName=" + encodeURIComponent(item.prod_name),{headHidden:true});
}
}
}
</script>
# API
# ~openURL (url,options)~
打开新的JSNative页面
# 参数
url {string}
:JSNative页面的地址options{object}
:选项参数对象landscape{bool}
:true
表示横屏打开页面,false
表示页面不需要横屏打开,默认为false
。 注意:为true
时,需要对应的JSNative页面布局支持横屏方式headHidden{bool}
:true
表示隐藏系统的头部导航条,false
表示不隐藏头部导航条,默认为false
。
# 注意:
接口将要废弃,不推荐使用。若要打开新的JSNative页面,请使用navigator模块中push方法。
# openNative (moduleName,options)
打开LightOS中Native模块组件,如web容器组件、自选股组件等。
# 参数
moduleName {string}
:模块组件名称,如web,mystock,search等options{object}
:选项参数对象,参数gmu组件支持的都可以