html - Jade 中不允许重复属性 "{"

标签 html node.js express pug chartist.js

我正在尝试将脚本放入 Jade 中,但它不允许我使用多个花括号。这是我试图放入 jade 中的图表代码。

body
    h1 Crimes by Category
    .ct-chart
    script(new Chartist.Bar('.ct-chart', {
    labels: ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
    series: [20, 60, 120, 200, 180, 20, 10]
    }, {
    distributeSeries: true
    });)

我收到不允许重复属性“{”的消息。我不知道如何解决这个问题。任何帮助,将不胜感激。

最佳答案

要在 Jade 中插入多行 javascript,请使用 script. 标签(脚本内容缩进):

body
    h1 Crimes by Category
    .ct-chart

      script.
        new Chartist.Bar('.ct-chart', {
        labels: ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
        series: [20, 60, 120, 200, 180, 20, 10]
        }, {
        distributeSeries: true
        });

如果您希望将 script. 缩进 .ct-chart div 中,您可能还需要将它缩进一格。

来源:How can I render inline JavaScript with Jade / Pug?

关于html - Jade 中不允许重复属性 "{",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34504956/

相关文章:

javascript - 正则表达式在不破坏现有 HTML 代码的情况下转换链接中的主题标签

javascript - Highcharts 子弹图错误 #13

python - 安装Appium的一些问题

javascript - 如何从 Node js 端获取基本路径?

javascript - 使用负边距来控制 flex-box 中的空间

html - 滚动时固定位置元素在 Chrome 中闪烁

node.js - 在 AngularJS、NodeJS、MongoDB、Mongoose 和 ExpressJS 中使用单个表单发布到多个集合

node.js - Express js 阻止 GET/favicon.ico

javascript - 在 Express.js 中,我是否应该返回响应?

javascript - Passport 验证不重定向