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页面
参数
openNative (moduleName,options)
打开LightOS中Native模块组件,如web容器组件、自选股组件等。
参数
moduleName {string}
:模块组件名称,如web,mystock,search等
options{object}
:选项参数对象,参数gmu组件支持的都可以