【发布时间】:2018-10-25 13:45:37
【问题描述】:
假设我有一个功能组件:
<template functional>
<div>Some functional component</div>
</template>
现在我在一些带有类的父级中渲染这个组件:
<parent>
<some-child class="new-class"></some-child>
</parent>
结果 DOM 没有将 new-class 应用于功能子组件。现在据我了解,Vue-loader 将 Functional 组件针对 render 函数 context 编译为 explained here。这意味着类不会被直接应用和智能合并。
问题是 - 在使用模板时如何使函数式组件与外部应用的类很好地配合?
注意:我知道通过渲染功能很容易做到这一点:
Vue.component("functional-comp", {
functional: true,
render(h, context) {
return h("div", context.data, "Some functional component");
}
});
【问题讨论】:
标签: javascript vue.js vuejs2 vue-component