alibaba / weex

A framework for building Mobile cross-platform UI
https://weexapp.com/
Apache License 2.0
18.28k stars 2.13k forks source link

weex使用原生导航栏 通过自定义openURL vue界面怎么实现a.vue跳转到b.vue #2599

Closed SeongBrave closed 3 years ago

SeongBrave commented 7 years ago

需要使用原生的导航栏,所以跳转界面是通过自定义module,添加openURL方法实现具体使用如下

var event = weex.requireModule('event')
event.openURL('http://xxx/weex/app.weex.js');

现在想实现效果为

var event = weex.requireModule('event')
event.openURL('b.vue');

swift端的实现是

public extension WXEventModule {
    public func openURL(_ url:String) {
        var newUrl:String = url;
        if url.hasPrefix("//") {
            newUrl = String.init(format: "http://%@", url);
        }else if !url.hasPrefix("http") {
            //relative path
            newUrl = (NSURL.init(string: url, relativeTo: weexInstance.scriptURL)!.absoluteString)!
        }
        print(url)
        let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
        let mainVc = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
        mainVc.url = newUrl
        weexInstance.viewController.navigationController?.pushViewController(mainVc, animated:true)
    }
}

通过打断的知道直接dist 目录下找对应的js文件 901040100-58a5467586012_articlex

这样我可以将b.vue对应的生成到dist目录下就可以实现,但是觉得这样太麻烦了,有没有更好的办法呢?

YorkShen commented 5 years ago

This PR/issue doesn't received response since Weex migrated to Apache two years ago and this repository is no longer active yet.

Feel free to ask question in new repository and thanks for your contribution.

Hanks10100 commented 3 years ago

This issue is outdated for a long time and will be closed now. You can create a new one if you still have questions.