小编Miz*_*lul的帖子

包含背景大小不起作用

我在使用Reactjs的render()函数中声明了以下html

 <div className={"companyImages"}>
    <div className={"thubm"} style={{background:'url(https://lumiere-a.akamaihd.net/v1/images/character_mickeymouse_home_mickey_notemplate_3a0db1b2.jpeg?region=0,0,600,600&width=320)'}}></div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的CSS如下所示:

.companyImages div {
  display: inline-block;
  margin:4px;
  width:51px;
  height:51px;
}

.companyImages .thubm {
  border-radius: 3px;
  background-size: contain;
  background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)

当前状态:仅显示图像的一小部分.

已过滤:整个图像调整大小并适合div.

截图:

在此输入图像描述

您可以在新标签中查看图像链接并分别查看整个图像.

html css html5 css-selectors css3

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

如何在React中选择选项等元素上存储和访问数据属性

我想从选项中获取数据属性使用react但由于某种原因我无法使用并且我得到null.

<select onChange={(e) => this.onIndustryChangeOption(e)} value={this.props.selectedIndustry}>
    <option value="" data-industry="industry1">Select Industry</option>
    <option value="" data-industry="industry2">Select Industry 2</option>
</select>

onIndustryChangeOption(event, index, value) {
   console.log(event.target.getAttribute('data-industry'));
   this.props.setRootState({selectedIndustry: event.target.value});
}
Run Code Online (Sandbox Code Playgroud)

这不起作用,我相信应该有其他方法来做到这一点!

html javascript ecmascript-6 reactjs

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

如何在 React 中执行返回功能

我正在使用react-router v.4,我想执行一些返回功能。

我当前的代码如下所示:

<HashRouter>
       <Switch>
            <Route exact path='/' component={Main}/>
            <Route path='/secondview' component={SecondView}/>
            <Route path='/traineeships' render={()=>(<Traineeship rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
            <Route path='/information-filter' render={()=>(<InformationFilter rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
            <Route path='/find-work' render={()=>(<FindWork rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
            <Route path='/information-job' render={()=>(<InformationJob rootState={this.state} setRootState={this.setState.bind(this)} />)}/>
            <Redirect from='*' to='/' />
       </Switch>
Run Code Online (Sandbox Code Playgroud)

this.props.history.go(-1)在其他组件上尝试了几个选项,但我遇到了未定义的错误。

任何人都知道如何在我的情况下执行返回功能?

javascript reactjs react-native react-router-v4

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

Can I pass multiple components within connect redux

I would like to have a smart component/container that handles CRUD operations for Product entity and I have the following code:

function productContainerRender(WrappedComponent) {
    return class extends React.Component {
        constructor(props) {
            super(props);
            this.fetchProducts = this.fetchProducts.bind(this);
        }

        fetchProducts = (page) => {
            this.props.dispatch(fetchProductsBegin());
            productsApi.getAll(page)
                .then(response => {
                    if (response.data) {
                        this.props.dispatch(fetchProductsSuccess(response.data._embedded.companies));
                    } else {
                        this.props.dispatch(fetchProductsFailure({message: "Fetching products failed"}));
                    }
                });
        };

        componentDidMount() {
            // this.fetchProducts(1);
        }

        render() {
            // ... and renders the wrapped component with the fresh data!
            // Notice …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-redux

1
推荐指数
2
解决办法
6670
查看次数

如何在 Dialogflow 的响应部分显示用户输入

我想在响应部分打印出用户输入,但由于某种原因,我似乎无法找到如何执行此操作。

例如:

Bot: How old are you?
User: 40
Bot: Your age is 40.
Run Code Online (Sandbox Code Playgroud)

我还附上了一个屏幕截图,其中我有一个参数,但我只是不知道该算什么年龄。 在此处输入图片说明

目前我得到你的年龄是 100,因为我手动添加了 100 作为年龄参数的值。对此有什么想法吗?

google-cloud-platform dialogflow-es

0
推荐指数
1
解决办法
874
查看次数