小编Eri*_*ica的帖子

内联if语句java,为什么不工作

描述:compareChar返回true或false.如果为true,则设置button的值,如果false则不执行任何操作.

我想使用:如果compareChar(curChar,toChar("0"))?.getButtons()得到(I).setText( "§");

netbeans说:')'除了':'除外

我试过这些组合:

if compareChar(curChar, toChar("0")) ? getButtons().get(i).setText("§");
Run Code Online (Sandbox Code Playgroud)

谢谢

java if-statement inline

16
推荐指数
3
解决办法
9万
查看次数

古腾堡-一种块状类型的多个内部块

我正在尝试使自定义列阻止,因为gutenberg使用的wordpress默认不是我所需要的。

因此,我查看了它的工作方式,它使用带有布局定义的InnerBlocks块,但是无法为列指定html标签和类,因此对我来说毫无用处。

然后,我决定使用map循环出列,效果很好,然后我在每列内部添加了InnerBlocks组件,以允许向该列插入其他块,但是问题是在每列中InnerBlocks的内容是共享的,所以我试图将每个InnerBlock和column的键属性设置为唯一,并且它们的内容仍然共享(不,我不使用共享块)。

好像gutenberg在每一列中都使用了相同的InnerBlocks实例。

我正在尝试构建一个块类型,您可以在其中动态添加列,并在每列中添加带有一些信息的“卡片”。

为了让我知道我在做什么,这是edit函数的返回:

<section className="infonav">
            <div className="infonav__container">
                <div>
                    <button onClick={onAddBox}>{__('Add column', 'zmg-blocks')}</button>
                </div>
                <div className="infonav__row">
                    {[...new Array(columns).keys()].map((item, index) => {
                        return (
                                <div className="infonav__row__col" key={"info_cols"+index}>
                                    <div>
                                        <button onClick={onRemoveBox.bind(index)}>
                                            {__('Remove', 'zmg-blocks')}
                                        </button>
                                    </div>
                                    <InnerBlocks key={"info_boxes"+index}/>
                                </div>
                        );
                    })}
                </div>
            </div>
        </section>
Run Code Online (Sandbox Code Playgroud)

谢谢

wordpress wordpress-gutenberg gutenberg-blocks

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

迷你购物车更改未生效 - Magento 2

我需要更改主题中的迷你购物车,使其回退到 magento 2 luna 主题,以使用悬停而不是单击来显示它。

所以我复制了

/vendor/magento/module-checkout/view/frontend/templates/cart/minicart.phtml 
Run Code Online (Sandbox Code Playgroud)

/app/design/frontend/[ourCompany]/[websitename]/Magento_Checkout/templates/cart/minicart.phtml
Run Code Online (Sandbox Code Playgroud)

编辑了文件:

....
<div class="block block-minicart empty"
             data-role="dropdownDialog"
             data-mage-init='{"dropdownDialog":{
                "triggerEvent" : "hover",
                "appendTo":"[data-block=minicart]",
                "triggerTarget":".showcart",
                "timeout": "2000",
                "closeOnMouseLeave": true,
                "closeOnEscape": true,
                "triggerClass":"active",
                "parentClass":"active",
                "buttons":[]}}'>
....
Run Code Online (Sandbox Code Playgroud)

清除缓存、刷新缓存、刷新缓存类型、清除静态内容、删除从 /var 生成和缓存的所有内容...

然后我重新运行静态内容部署。启用模板路径提示,显示 minicart.phtml 是从以下位置加载的:

/app/design/frontend/[ourCompany]/[websitename]/Magento_Checkout/templates/cart/
Run Code Online (Sandbox Code Playgroud)

所以没关系。但网站上的改动并没有发生变化。所以我检查了

/var/view_prepro.../app/design/frontend/[ourCompany]/[websitename]/Magento_Checkout/templates/cart/minicart.phtml
Run Code Online (Sandbox Code Playgroud)

文件的更改不存在。所以我做了更多的改变(添加了一些html)...清除缓存,刷新缓存,刷新缓存类型,清除静态内容,删除从/var生成和缓存的所有内容...

然后我重新运行静态内容部署。

网站上仍然没有任何变化。

当我更改 Mage_Catalog 或其他模块中的某些内容时,一切都工作正常。

我正在使用 Magento 2.1.5

感谢您提供任何可能的解决方案、想法...

php themes caching magento magento2

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

创建小部件时的 Flutter redux 调度事件

我想在构建小部件时使用 redux 操作加载数据。比如说:

用户打开应用程序,然后呈现 HomeScreen 组件,此页面上有一些类别。

我已经实现了支持多个商店(尚未测试)的 AppState,该商店使用 FlutterStorage 在 main() 中填充初始数据。

因此,在 HomeScreen 中,我可以使用 StoreConnector 从 build() 访问数据,因为在转换器中我将获得商店,因此我可以调度事件或读取应用程序状态。但这只是在 build() 内部有问题,因为如果在 render 方法中调度 LoadCategories 事件,那么它将进入无限循环。

在 reactjs 中,我能够将调度映射到组件(小部件)属性,因此在 componentDidMount 中我能够获取数据。这在 Flutter 中似乎是不可能的。

任何想法如何实现这一目标?

谢谢

redux flutter

4
推荐指数
2
解决办法
1785
查看次数

如果用户状态为非活动状态,则阻止用户登录

我试图阻止用户登录,他的状态为非活动状态。我正在将 API 平台与 LexikJWT 捆绑包一起使用。

我尝试JWTAuthentication通过扩展来进行防护JWTTokenAuthenticator->checkCredentials,但问题是这在用户登录后才起作用。

我想要实现的是向用户返回一条消息,要求他首先激活其帐户,或任何其他消息,最好是任何自定义条件下的任何自定义消息。

我的安全 YAML 如下所示:

security:
    encoders:
        App\Entity\User:
            algorithm: bcrypt
    providers:
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email
    firewalls:
        dev:
            pattern: ^/_(profiler|wdt)
            security: false
        api:
            pattern: ^/api/
            stateless: true
            anonymous: true
            provider: app_user_provider
            json_login:
                check_path: /api/authentication_token
                username_path: email
                password_path: password
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure
            guard:
                authenticators:
                    - app.jwt_token_authenticator
        main:
            anonymous: true
    access_control:
        - { path: ^/api/authentication_token,   roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api/graphql,                roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/public-api,                 roles: IS_AUTHENTICATED_ANONYMOUSLY …
Run Code Online (Sandbox Code Playgroud)

php symfony symfony-security symfony4 symfony5

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

FloatingActionButton backgroundColor 默认为重音颜色

我已从https://github.com/flutter/flutter/issues/28138重定向到这里。

通常我的问题是我不认为 FloatingActionButton backgroundColor 和 FlatButton 文本颜色是从 ThemeData 中定义的正确值继承的。

  1. 创建一个应用程序,您将在其中使用主要红色(应用程序栏、按钮 bg、卡片),黄色用于强调(图标、应用程序栏标题),黑色用于一般文本,白色/浅灰色用于脚手架主体等背景。
  2. 使用主题 (primaryColor) 将 AppBar BG 颜色设置为红色
  3. 使用主题 (accentColor) 将 AppBar 标题颜色设置为黄色
  4. 将图标的颜色设置为与重音颜色相同的颜色,因为如果使用原色,它们将在 AppBar 中不可见
  5. 创建一个带有图标的浮动操作按钮。
  6. floatActionButton 中的图标不可见,因为小部件的 backgroundColor 使用黄色的 ThemeData.accentColor 而不是 ThemeData.primaryColor

前景和背景都默认为重音颜色。

 /// The color to use when filling the button.
 ///
 /// Defaults to **[ThemeData.accentColor**] for the current theme.
 final Color backgroundColor;
Run Code Online (Sandbox Code Playgroud)

我在对话框中发现了与 FlatButton 类似的问题,默认情况下,文本的颜色是强调色,即黄色(在白色背景上),如果我将其覆盖为主色,则它是红色的,但我不想让它变成红色,因为旁边的删除按钮是红色的。所以我需要将它设置为正常,所以它是黑色的,这是正确的,但是:

flat_button.dart:127

 /// The color to use when filling the button.
 ///
 /// Defaults to **[ThemeData.accentColor**] for the current theme.
 final …
Run Code Online (Sandbox Code Playgroud)

material-design flutter

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

pdo,将php对象插入数据库

我找不到这个问题的答案。

我想将一个PHP对象保存到MySQL数据库中。例:

class user{
  private $id, $email, $pw, $first, $last, $group,.....;
 // getters and setters    
}

class someclass{

public function someFunction(){
  $pdo = new PDO(...);
  $objUser = new user();
  $objUser->setEmail(....);
  $objUser->setFirst(....);
  //bla bla bla

 // and I want to save this user object to the DB with something like:
  $pdo->insert($objUser); //in this case db table equals to class name
  //instead of building/writing query manually. 
  //for mysql_query I have made a class for building queries for insert, update and delete 
  //but …
Run Code Online (Sandbox Code Playgroud)

php mysql pdo object

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

reactjs-输入defaultValue已设置但未显示

注意到有些奇怪的地方是为输入设置了defaultValue,但是有时刷新页面时它不可见。我尝试过console.log,然后在加载数据时多次重新渲染组件,在最后一次重新渲染时,组件包含所需的值,如屏幕截图所示,但未显示。知道为什么吗?谢谢

<input type="text" name={this.props.question.id}
                defaultValue={defaultValue}
                onChange={this.onSingleChange.bind({
                    selectAnswer: this.props.selectAnswer,
                    question: this.props.question,
                    form: this.props.fid
                })}
                className="form-control"
            />
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

input reactjs react-redux

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

c ++矢量多个值

我是c ++的新手,但是有半年的Java se/ee7工作经验.

我想知道如何将3个值放入vector<string> 示例中:vector<string, string, string>或者只是vector<string, string> 为了避免使用3个向量.

vector<string> questions;
vector<string> answers;
vector<string> right_answer;

questions.push_back("Who is the manufacturer of Mustang?");
answers.push_back("1. Porche\n2. Ford \n3. Toyota");
right_answer.push_back("2");

questions.push_back("Who is the manufacturer of Corvette?");
answers.push_back("1. Porche\n2. Ford \n3. Toyota \n4. Chevrolette");
right_answer.push_back("4");


for (int i = 0; i < questions.size(); i++) {
    println(questions[i]);
    println(answers[i]);

    if (readInput() == right_answer[i]) {
        println("Good Answer.");
    } else {
        println("You lost. Do you want to retry? y/n");
        if(readInput() == "n"){
            break;
        }else{ …
Run Code Online (Sandbox Code Playgroud)

c++ stdvector

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