• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
LDLX@Y火星
博客园    首页    新随笔    联系   管理    订阅  订阅

react native中使用 react-native-easy-toast 和react-native-htmlview

第一步,下载依赖

npm install react-native-htmlview --save

npm install react-native-easy-toast --save

第二步,引入

import Toast, {DURATION} from 'react-native-easy-toast'
import HTMLView from 'react-native-htmlview';

第三步,使用

export default class App extends Component{
    render(){
        const htmlContent = `<p><a href="https://www.cnblogs.com/ldlx-mars/p/9360650.html">火星黑洞</a></p>`;
        return(
            <View>
                <Text onPress={()=>{this.refs.toast.show('hello world!',500)}}>我是首页</Text>
                <Toast ref="toast" position='center' opacity={.8}/>
                <HTMLView
                    value={htmlContent}
                    stylesheet={styles}
                />
            </View>
        )
    }
}

然后执行项目

完整代码是,app.js

import React, { Component } from 'react';
import {  StyleSheet,View,Text } from 'react-native';
import Toast, {DURATION} from 'react-native-easy-toast'
import HTMLView from 'react-native-htmlview';
export default class App extends Component{
    render(){
        const htmlContent = `<p><a href="https://www.cnblogs.com/ldlx-mars/p/9360650.html">火星黑洞</a></p>`;
        return(
            <View>
                <Text onPress={()=>{this.refs.toast.show('hello world!',500)}}>我是首页</Text>
                <Toast ref="toast" position='center' opacity={.8}/>
                <HTMLView
                    value={htmlContent}
                    stylesheet={styles}
                />
            </View>
        )
    }
}

const styles = StyleSheet.create({
    a: {
      fontWeight: '300',
      color: '#FF3366',
    },
});

 

posted @ 2018-07-24 16:52  火星黑洞  阅读(2996)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3