Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
858 views
in Technique[技术] by (71.8m points)

weex 跳转h5页面,web和app需要用不同的处理方式吗?

目前我们移动端的网站都是h5的,app里也是嵌的h5,打算使用weex来进行改版。

所以目前是先只改一个页面,使用weex,页面中有跳转到h5页面的链接,使用的是a标签,在web中是可以直接跳转的,但是在app中跳到空白页,想请问下,weex写的页面,跳转到h5页面,web和app中处理方式不一样吗?那在app中怎么处理呢?谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

在官方示例hackernews项目中找到了解决方案:
判断当前的环境是web还是app,如果是web,则直接跳转;如果是app,则跳转到路由配置的页面,页面里加web组件,src指向h5链接

<template>
    <div>
        <web class="webview" :src="url"></web>
    </div>
</template>
<style scoped>
    .webview{
        flex:1;
    }
</style>
<script>
    export default {
        computed: {
            url(){
                if(this.$route && this.$route.params){
                    return this.$route.params.url
                }
                return 'http://m.taobao.com'
            }
        }
    }
</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...