uniapp-jump external links

uni.navigateTo jumps to an internal page we defined, and the internal page needs to jump to the external URL

1. First build an internal page 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>
 

Point to the internal path we jump to in page.json

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

Click to trigger jump

 <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界面去接收 实现跳转
      })
 
    }

Guess you like

Origin blog.csdn.net/SqlloveSyn/article/details/129001071