this.content.contractUrl为后端传输的url地址
- goh5() {
- if (this.content.signStatus == 1) {
- const url = this.content.contractUrl
- uni.navigateTo({
- url: '/pages/web/web?url=' + encodeURIComponent(JSON.stringify(url))
- })
- } else {
- const hurl = this.content.wxOfficialAccountUrl
- uni.navigateTo({
- url: '/pages/web/web?hurl=' + encodeURIComponent(JSON.stringify(hurl))
- })
- }
- }
- <view class="box">
- <web-view v-if="URL" :src="URL">web-view>
- view>
-
- <script>
- export default {
- data() {
- return {
- URL: undefined,
- }
- },
- onLoad(e) {
- // 传入需要跳转的链接 使用web-view标签进行跳转
- this.URL = JSON.parse(decodeURIComponent(e.url))
- },
- methods: {
-
- }
- },
- }
- script>
若传递参数中含有=,?,&等特殊字符 无法正常传递参数 则需要进行编码解码 传递时使用encodeURIComponent() 接收时使用decodeURIComponent()
- //传递处理
- let url = 'https://xxxxx.xxxx.com/mini/api/?id=2222&key=kkkkk'
- my.navigateTo({
- url: `/pages/Web/Web?url=${encodeURIComponent(JSON.stringify(url))}`
- })
-
- //页面接收
- onLoad(options) {
- console.log('Url---', options, decodeURIComponent(JSON.parse(options.url)));
- this.setData({
- url: decodeURIComponent(JSON.parse(options.url))
- })
- },