如何在React Native中使用HTML字符串?

时间:2017-08-31 14:51:02

标签: html react-native

我有一个常量变量,我拿着的HTML字符串只是一个按钮。现在我想在React Native应用程序中使用click按钮和一些CSS。

我的代码: -

import React from 'react';
import { StyleSheet, Text, View ,TouchableHighlight} from 'react-native';
import HTMLView from 'react-native-htmlview';

export default class App extends React.Component {
  constructor(){
    super();
    console.log("checking log...");
  }
     render() {
     const btn = `<button onClick="alert("Hey");">Hey click me</button>                  `
    return (
      // Try setting `justifyContent` to `center`.
      // Try setting `flexDirection` to `row`.
      <View style={{
       flex: 1,
        flexDirection: 'column',
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor:'red'
      }}>
       <View style={{width: 50, height: 50, backgroundColor: 'powderblue'}}>          
       </View>           
        <HTMLView value={btn}/>    
      </View>
    );
  }    
}
const styles = StyleSheet.create({
  button: {
   backgroundColor:'red',
   borderColor:'black',
    color: 'white', // make links coloured pink
  },
});

0 个答案:

没有答案