小编Huz*_*kil的帖子

动态改变背景图像

我想在提交城市名称时更改背景图像,但不知道如何动态更改背景图像..我一直在使用三元运算符,但没有给我所需的输出。(React-native noobie)

这是我的主要代码..

import React, {Component} from 'react';
import {Image, TextInput, ImageBackground, StyleSheet, Text, View} from 'react-native';
import OpenWeatherMap from './Components/openweathermap';
import WeatherForecast from './Components/forecast';
import Images from './android/app/assets/images';

export default class why extends Component {
constructor(props){
  super(props);
   this.state = {forecast: null, doesShow: false};
}
textHandleChange = event => {
 let city = event.nativeEvent.text;
 OpenWeatherMap.fetchWeather(city).then(forecast =>{
   this.setState({forecast : forecast});              //Used for fetching weather data using fetchAPI
 });
}


backgroundChange = () => {
  this.setState({doesShow:true})
}



  render(){
  let content = null; …
Run Code Online (Sandbox Code Playgroud)

react-native

5
推荐指数
1
解决办法
3095
查看次数

标签 统计

react-native ×1