uniapp-跳转外部链接

uni.navigateTo跳转到我们定义的一个内部页面,内部页面接收需要跳转到外部的URL

一、先建一个内部页面webview.vue

<template>
  <web-view :src="url"></web-view>
</template>
 
<script>
export default {
  data() {
    return {
      url: ''
    }
  },
  onLoad(item) {
    this.url = decodeURIComponent(item.url)
    console.log(this.url)
    // 传入需要跳转的链接 使用web-view标签进行跳转
  }
}
</script>
 
<style lang="scss">
</style>
 

在page.json里面指向我们跳转的这个内部路径

{
            "path" : "pages/common/webview"
 }

点击触发跳转

 <view class="uni-form-right" @click="hrefrouterApp()"> 平台跳转 </view>

js:

 // 触发跳转
    hrefrouterApp() {
      let url = 'http://xxxxxx/routerApp'  // URL是要跳转的外部地址 作为参数
      uni.navigateTo({
        url: '/pages/common/webview?url=' + url
        // page.json定义的路径 传url 到webview界面去接收 实现跳转
      })
 
    }

猜你喜欢

转载自blog.csdn.net/SqlloveSyn/article/details/129001071