Comments (3)
@hellogaojun 你好,不知道你说的是不是指要在 H5 里面写下面这段代码,H5 是不需要依赖这个框架的,只是在页面加载时,需要在 JavaScript 里面做一些初始化操作,理论上来讲,在你的 OC 里面加载 h5 网页前 evaluate 这段 js 也是可以的。
function setupWebViewJavascriptBridge(callback) {
if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
window.WVJBCallbacks = [callback];
var WVJBIframe = document.createElement('iframe');
WVJBIframe.style.display = 'none';
WVJBIframe.src = 'https://__bridge_loaded__';
document.documentElement.appendChild(WVJBIframe);
setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
}
setupWebViewJavascriptBridge(function(bridge) {
/* Initialize your app here */
bridge.registerHandler('JS Echo', function(data, responseCallback) {
console.log("JS Echo called with:", data)
responseCallback(data)
})
bridge.callHandler('ObjC Echo', {'key':'value'}, function responseCallback(responseData) {
console.log("JS received response:", responseData)
})
})
具体建议看看官方文档和源码。
from iosdevlevelingup.
谢谢你的解答,我是看我团队的H5端导入JSBridge这个框架,造成了一点误解!
from iosdevlevelingup.
@hellogaojun 不客气~
from iosdevlevelingup.
Related Issues (20)
- NSMapTable 和 NSHashTable HOT 1
- 计算机组成原理 HOT 2
- button 文字有两行时,图片上文字下,文字宽度有问题 HOT 2
- Protocol Buffer ("protobuf") HOT 1
- 英文文章阅读笔记 HOT 2
- WWDC HOT 6
- 如何提升技术深度? HOT 1
- 如何自学计算机专业课程?
- Lua 语言
- Lightweight Generics HOT 1
- Flutter HOT 2
- 周报(2019) HOT 25
- 热修复
- runloop HOT 1
- 汇编语言 HOT 1
- 爬虫与反爬虫 HOT 1
- UICollection View not Scrolling vertically
- A/B Testing HOT 1
- IM 即时通讯 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iosdevlevelingup.