小程序登录跳转页面

601 阅读1分钟

实现跳转H5需要用到小程序的web-view(因为外部h5无法跳转到小程序,因此需要把h5内嵌到小程序的web-view中)

web-view:承载网页的容器。会自动铺满整个小程序页面。

src属性:指向网页的链接。可打开关联的公众号的文章(其它网页需登录小程序管理后台配置业务域名)

第一步:

给image添加点击事件go

<swiper indicator-dots circular autoplay>

    <swiper-item wx:for="{{imageList}}" wx:key="index">

        <image style="width: 100%;" bindtap="go" src="{{item.image}}"

        data-path="{{item.path}}"

        ></image>

    </swiper-item>

</swiper>
复制代码

第二步:

设置跳转lianjie页面

go:function(e){

     let {currentTarget:{dataset:{path}}} = e;

      wx.navigateTo({

        url: '/pages/lianjie/lianjie?url=' + path,      })    }
复制代码

第三步:

创建lianjie页面,使用web-view

<web-view src="{{url}}"></web-view>
复制代码

第四步:

设置url值为空,获取点击图片所对应的链接地址

 data: {

        url:''

    },

    onLoad: function (options) {

        console.log(options);

        this.setData({

            url:options.url        })    }