小编tib*_*www的帖子

onclick 道具不适用于 Material UI?

这是我在 React.js 上的情况

我的 App.js 调用 selectNumberOfPeople 上有一个函数,

然后在我的子组件(调用 General)中,我有一个按钮:

<button className="selectedNumberOfPeopleButton" onClick={this.selectedNumberOfPeople} value="1">
      1
</button>
Run Code Online (Sandbox Code Playgroud)

单击时在控制台中显示值。

完美运行。

我现在想改用 Material UI 中的按钮,因此我将按钮替换为:

<RaisedButton className="selectedNumberOfPeopleButton" 
    onClick={this.props.selectedNumberOfPeople}
    value="1" 
    label="1" 
    labelPosition="before"
    primary={true}
/>
Run Code Online (Sandbox Code Playgroud)

但是在使用 this 时,控制台中不再显示该值。. .

虽然函数在父组件中,但我确实通过了它:

<General selectNumberOfPeople={this.selectNumberOfPeople} selectedPanel={this.showPanelAndHideOthers} />
Run Code Online (Sandbox Code Playgroud)

我尝试更新我的子组件(General.js),例如:

<RaisedButton selectNumberOfPeople={this.props.selectNumberOfPeople}
    className="selectedNumberOfPeopleButton" 
    onClick={this.props.selectedNumberOfPeople}
    value="1" 
    label="1" 
    labelPosition="before"
    primary={true}
/>
Run Code Online (Sandbox Code Playgroud)

但它仍然无法正常工作......

供您参考,

selectNumberOfPeople 在 App.js 中作为

selectNumberOfPeople(value) {
console.log('select number of people');
// update the state and provide a callback handler to be called after the state is updated.
// referencing …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-props

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

在目录页面上显示标签woo commerce - wordpress

如果有办法用woocommerce(wordpress插件)在目录页面上显示产品的标签,我看起来像个疯子.我找不到关于ti的任何内容,我一直试图调整代码,但没有成功...

如果有人有一些高级精简版,它会很精彩,

非常感谢你

tags wordpress woocommerce

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

在悬停功能上,如果X有类,请执行此操作

我有一个函数,在悬停时,为一个元素添加一个类.

我希望只有在另一个div具有特定类时才会发生这种情况.

到目前为止,我正在尝试这个没有任何结果:

$('.title-overlay').hover(

   function(){ 


    $(this).addClass('title-hover'),

   },

   function(){
   if($('.wmg-container3').hasClass('open')){
    $(this).removeClass('title-hover'),
 }
}
)
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我希望title-hover添加类,但如果wmg-container3有类open,则应删除此类.

(所有这些都悬​​停在类标题叠加层上)

谢谢你们的帮助!

javascript jquery addclass removeclass

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