React + Taro 小程序跳转公众号

3 篇文章 0 订阅
2 篇文章 0 订阅

Taro小程序跳转公众号的文章

步骤:登录公众号后台-小程序-小程序管理-添加-关联小程序

关联后就可以在微信的公众平台查看(设置-关联设置-关联公众号)
如图所示:
在这里插入图片描述

然后使用web-view

我这个是使用广告轮播实现的代码如下

注意:一个页面使用一个web-view 所以我使用遍历传值到跳转地址的页面

html代码

 {/* 跳转公众号的文章 */}
        <View>
          <AtCurtain
            isOpened={this.state.isOpened}
            onClose={this.onClose.bind(this)}
            closeBtnPosition:true
          >
            <Swiper
              className="swip-curtain"
              indicatorColor="#999"
              indicatorActiveColor="#333"
              circular
              autoplay
              indicatorDots="true"
              indicatorActiveColor="#0080ff"
            >
              {ad.map((item, index) => {
                return (
                  <Navigator url={`${item.jumpUrl}?webUrl=${item.webUrl}`} key={index}>
                    <SwiperItem>
                      <View className="demo-text-1">
                        <Image
                          className="swip-image"
                          style="width: 100%;height:500rpx;background: #fff;"
                          src={item.image}
                        />
                      </View>
                    </SwiperItem>
                  </Navigator>
                );
              })}
            </Swiper>
          </AtCurtain>
        </View>

js代码

//接收传入的文章地址
 componentDidMount(){
    // this.getAdImg()
    const { webUrl } = this.$router.params;
    this.setState({
      webUrl: webUrl,
    });
    console.log("传入的值")
    console.log(webUrl);
  }

// 遍历到对应的web-view上
	render() {
    return (
      <View>
      	<web-view src={this.state.webUrl}></web-view>
      </View>
    );
  }

如果觉得文章还行的话,可以给我一颗小星星嘛,谢谢啦 ~~

加油元芳,明天会更好的 ~~

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值