我正在尝试使用Hypernova和vueonrails助手将Vue.js组件添加到支持SSR的Ruby-on-Rails应用程序中。
我可以使用这个帮助器从视图(.html.erb)呈现一个使用Hypernova注册的组件:
<%= render_vue_component('HelloWorld', message: 'Hello World from SSR!') %>假设我的HelloWorld组件的模板中有一个<slot>:
<template>
<div class="helloworld">
<h1>{{ message }}</div>
<slot></slot>
</div>
</template>我想使用render_vue_component在.html.erb中复制如下内容
<hello-world message="Hello World from SSR!">
<hello-world>SSR Nested component</hello-world>
</hello-world>我如何将子元素传递给render_vue_component帮助器,以便它们被Hypernova渲染?
发布于 2020-11-25 07:39:27
好吧,我分析了代码库,通过查看它,我认为您应该只使用render_vue_component来呈现根组件,就像使用@vue/cli启动项目时的main.js一样
<%= render_vue_component('App', { router }) %>我是通过分析vueonrails源代码得出这个结论的。
如果看一下render_vue_component function,它只接受标识符和一个内部调用render_react_component的数据对象。
通过这个签名,它根本不适合(element, children)或(element, attributes, children)的Vue's render function签名。
也许你会发现opening an issue on the repo提供了更好的支持。
但在使用这个项目之前,我会三思而后行,因为到目前为止还没有任何文档,检查website,似乎他们更专注于销售关于该项目的书籍,而不是创建文档。
https://stackoverflow.com/questions/64994619
复制相似问题