UI与脚本互通交互
说明
tip
- 本章节主要讲述H5 UI.JS 以及 脚本,三者互通交互
- 该功能从iOS 脱机版本 5.10.0+才能使用
如何使用
- 在idea工程中新建脱机的项目,自带的就有交互的实例
H5->ui.js->脚本调用的流程
tip
- 脚本注册一个函数给ui.js,函数是 registeScriptFunctionToUI
- ui.js注册一个H5函数给H5页面,函数是 ui.registeH5Function
- H5 发起调用到ui.js中,ui.js再次调用脚本注册的函数
H5 文件内容
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link href="htmljs/bootstrap.min.css" rel="stylesheet">
<script src="htmljs/bootstrap.min.js"></script>
<script src="htmljs/jquery.min.js"></script>
</head>
<body>
<div class="alert alert-info" role="alert">
开始脚本配置
</div>
<div style="margin: 10px">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="autoService" disabled>
<label class="form-check-label" for="autoService">自动化服务</label>
<span class="badge text-bg-info bg-primary" onclick="refreshIsServiceOk()">