美文网首页
跳转外部链接或者应用市场

跳转外部链接或者应用市场

作者: 宏_4491 | 来源:发表于2020-07-27 10:25 被阅读0次

项目情景是要跳转安卓市场和ios市场

  • h5 的话可以使用location.href="www.baidu.com"
  • 小程序使用location.href 会报错
  • 小程序只能用web-view来展示
    1 先建立一个webView目录,在目录里创建一个webView.vue 文件


    image.png

2 然后使用uni.navgateTo()去跳转页面

uni.navigateTo({
                    url:'/pages/webView/webView?url=https://itunes.apple.com/app/id1494256104'
                })

3 在webView.vue 里面放一个web-view 标签 设置src=''传过来的地址"

<template>
    <view>
        <web-view :src="url"></web-view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                url:""
            }
        },
        onLoad(e) {
            console.log(e)
            this.url=e.url
        }
    }
</script>

<style>
</style>

相关文章

网友评论

      本文标题:跳转外部链接或者应用市场

      本文链接:https://www.haomeiwen.com/subject/mxwalktx.html