首页 > 解决方案 > 车把内联css

问题描述

我想使用把手传递像 style="background-color: value" 这样的内联 css。

我有js文件

module.exports = {
  header: 'some title',
  boxes: ["here some objects"],
  style: {
    backgroundCol: '#000',
    textCol: '#f00',
    numbersCol: '#c31d5a',
    titleSize: '28px',
    numbersSize: '42px',
  }
}

我使用#each 循环来获取所有框,并希望通过这些样式来设置它们的样式。我试图以这种方式做到这一点:

<div class="test" style="background-color: '{{style.backgroundCol}}'">

使用内联样式的正确方法是什么,或者有什么方法可以将此“样式”对象传递给样式表并使用类?

标签: csshandlebars.jsinline-styles

解决方案


推荐阅读