xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

小程序 web-view

小程序 web-view

https://opendocs.alipay.com/mini/component/web-view

https://opendocs.alipay.com/mini/api/webview-context

https://opensupport.alipay.com/support/knowledge/46919/201602349122?ant_source=zsearch


https://opensupport.alipay.com/support/helpcenter/190

https://opendocs.alipay.com/search?keyword=web view&pageIndex=1&pageSize=10&type=qa


webview

  1. Open H5 url

    if (replace) {
      Taro.redirectTo({
        url,
      })
    } else {
      Taro.navigateTo({
        url,
      })
    }

  1. web-view component with H5 url ??? auto render bug

open iframe page (taro router) ???


// import Taro, { Component } from '@tarojs/taro'
import Taro, { Component, Config } from '@tarojs/taro'

import {
  View,
  Text,
  WebView,
} from '@tarojs/components'
import './index.scss'

// import classNames from 'classnames'
// import PropTypes, { InferProps } from 'prop-types'

const log = console.log;

export default class IframeComponent extends Component {
  config = {
    navigationBarTitleText: '购买须知'
  }
  constructor (props) {
    super(props)
    const {
      url,
    } = props
    this.state = {
      link: url || ``,
    };
  }

  componentWillReceiveProps(nextProps) {
    const {
      url,
    } = nextProps;
    if (url !== this.state.link) {
      this.setState({
        link: url || ``,
      })
    }
  }

  componentWillMount () { }

  componentDidMount () { }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  stopDefaultEvent = (e) => {
    e.preventDefault();
    e.stopPropagation();
    return;
  }

  render () {
    // const {
    //   link,
    // } = this.state;
    const {
      url,
    } = this.props;
    return (<WebView className='iframe-container' src={link} onMessage={this.stopDefaultEvent} />);
    // const {
    //   url,
    // } = this.props;
    // return (<WebView className='iframe-container' src={url} onMessage={this.stopDefaultEvent} />);
  }
}

IframeComponent.defaultProps = {
  url: '',
}




©xgqfrms 2012-2025

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @   xgqfrms  阅读(393)  评论(2编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-04-11 vue & iview
2019-04-11 Chrome Extensions Development All In One
2019-04-11 CMD & Git Shell & Bash Shell
点击右上角即可分享
微信分享提示