简体   繁体   English

如何在 Ext JS 7 中使用自定义 sass

[英]How to use custom sass in Ext JS 7

I have been trying to change the button colour in a form I have created on Ext JS v7.0.0.40我一直在尝试更改我在 Ext JS v7.0.0.40 上创建的表单中的按钮颜色

Login.js location is app\\modern\\src\\view\\main\\Login.js Login.js 位置是 app\\modern\\src\\view\\main\\Login.js

  extend: "Ext.form.Panel",
  xtype: "form-login",
  title: "Login Form",

  bodyPadding: 20,
  width: 320,
  autoSize: true,

  items: [
    {
      xtype: "textfield",
      allowBlank: false,
      required: true,
      label: "User ID",
      name: "user",
      placeholder: "user id"
    },
    {
      xtype: "passwordfield",
      allowBlank: false,
      required: true,
      label: "Password",
      name: "pass",
      placeholder: "password"
    },
    {
      xtype: "checkbox",
      boxLabel: "Remember me",
      name: "remember"
    }
  ],

  buttons: [
    {
      text: "Login",
      handler: "onLogin"
    }
  ]
});

Login.sass location is app\\modern\\sass\\var\\view\\main\\Login.sass Login.sass 位置是 app\\modern\\sass\\var\\view\\main\\Login.sass

.form-login {
  .button {
    background-color: #ff3737;
  }
}

For some reason I cannot get the color of the button to be changed, I'm sure this has a pretty simple fix.出于某种原因,我无法更改按钮的颜色,我相信这有一个非常简单的修复方法。

Thanks in advance!提前致谢!

Welcome to Stack Overflow:欢迎使用堆栈溢出:

You did not set the cls (custom class for the element) for the form.您没有为表单设置cls (元素的自定义类)。

And the button styling for the background-color is done in a subelement:背景颜色的按钮样式是在子元素中完成的:

scss file: .scss 文件:

.form-login {
  .x-button .x-inner-el {
    background-color: #ff3737;
  }
}

https://fiddle.sencha.com/#view/editor&fiddle/325q https://fiddle.sencha.com/#view/editor&fiddle/325q

Further information:更多信息:

  • To find out yourself, you can inspect the button and see that,要了解自己,您可以检查按钮并看到,
    • the button cls is x-button按钮 cls 是x-button
    • adding the background color to the x-button will not help将背景颜色添加到 x 按钮将无济于事
    • going further down inside the x-button is the x-button-el and adding the background color there will acutally change the color.在 x-button 内进一步向下是 x-button-el 并在那里添加背景颜色将实际改变颜色。
  • The scss file should go parallel to the form-login file, but you do not have to do that. scss 文件应该与表单登录文件并行,但您不必这样做。
  • If you plan to use this type of color如果你打算使用这种类型的颜色
    • more often: Use a cls and create a custom component with that style更频繁地:使用cls并创建具有该样式的自定义组件
    • always: Take a look at the documentation to change the button background color in your theme始终:查看文档以更改主题中的按钮背景颜色

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM