Fetch image from URL and set as background in React JS
我想从 URL 中获取图像并显示它。
我将 url 作为 URL 文本字段中的输入,当我在 img 标签中使用它时,它的工作原理就像但是当我在 td 背景中传递或使用它时它不起作用
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
import React, { Component } from ‘react’;
class ImageStyle extends Component { constructor(props) { this.state = { this.handleInputChange = this.handleInputChange.bind(this); handleInputChange(event) { this.setState({ } render() { return ( <br /> <br /> } export default ImageStyle; |
指定表格的样式并提及背景图片 url,如
1
|
backgroundImage: `url(${this.state.url})`
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
class ImageStyle extends Component {
constructor(props) { this.state = { this.handleInputChange = this.handleInputChange.bind(this); handleInputChange(event) { this.setState({ } render() { <br /> <br /> } |
- 我尝试了一些不同的方法你能帮忙吗? stackoverflow.com/questions/43408824/…
- 如果您可以在链接中提供帮助,那将是一个巨大的提升,因为它将在其他几个地方使用stackoverflow.com/questions/43408824/…
- Piyush,你能试试这个,让我知道它是否有效
- 你能帮忙吗? stackoverflow.com/questions/43455200/…
- 你知道如何多选下拉元素吗?如果你有时间告诉我,我会上传片段
- 我没有处理过多选下拉菜单,但是我认为 React 有一些可用的包
来源:https://www.codenong.com/43406383/