vue.js - 从 Vue 脚本中获取 Pug/Jade 混合参数

标签 vue.js pug

是否可以将 mixin 参数绑定(bind)到 vue 实例?

我有这个 mixin 来渲染表格:

mixin table(header,data,type)
- var type = type || ""
table.table(class=type)
    thead
        tr
            each head, i in header
                th #{head}
    tbody
        each row,j in data
            tr
                each col,k in row
                    td #{col}

可以这样正常使用:

+table-striped(["#","First Name","Last Name","Username"],[["1","Mark","Otto","@mdo"],["2","Jacob","Thornton","@fat"],["3","Larry","the Bird","@twitter"]])

我的问题是是否可以从 vue 实例中获取 mixin 的“header”和“data”参数。

最佳答案

我认为您混淆了服务器端渲染(Pug 所做的)和客户端渲染(Vue.js 通常用来完成的事情)。您不能在创建 HTML 后动态“调用”mixins,因为这需要 Pug 渲染器在后台某处运行,监听此类请求。另见 this comment在官方 Pug 存储库上的相关 Github 问题上。

但是,您仍然可以将 Vue.js 与 Pug 结合使用,只是不是以这种方式。不要使用混合,考虑制作一个自定义的 Vue.js 组件来获取类似的输入,然后通过 some JS-pug-variable magic 注入(inject)想要的数据。 .

关于vue.js - 从 Vue 脚本中获取 Pug/Jade 混合参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46119842/

相关文章:

javascript - 使用 vue.js 将循环变量作为 HTML <input> onclick 属性中的函数参数传递

javascript - Jade 选择字段填充数据

javascript - 谷歌地图需要很长时间才能加载

html - CSS如何制作可滚动列表

javascript - 使用 Express mongo 显示类别

express - 在Electronic Framework中使用Express JS和Vue.js

javascript - 如何修复 Vue 警告 : You may have an infinite update loop in a component render function

javascript - 在 EventListener 中使用 vue.js 方法点击其他方法

javascript - Vue.js 拦截器

javascript - NodeJS : Save menu order