简体   繁体   English

Riot.js 4、如何挂载嵌套标签

[英]Riot.js 4, how to mount nested tags

I'm creating application in Riot.js 4 and using in-browser compilation (for prototyping), everything was working fine in Riot.js 3. However, when I use nested tags, only the root tag is mounted and not any child tags.我正在 Riot.js 4 中创建应用程序并使用浏览器内编译(用于原型设计),在 Riot.js 3 中一切正常。但是,当我使用嵌套标签时,只有根标签被挂载,而不是任何子标签. If I mount every nested tag separately, they are mounted fine.如果我分别安装每个嵌套标签,它们安装得很好。

Minimal example is here: https://plnkr.co/edit/hxXUvmsjEgE3eDAF最小的例子在这里: https : //plnkr.co/edit/hxXUvmsjEgE3eDAF

<main>
    <p>main tag</p>
    <footer></footer>
</main>

<footer>
    <p>footer</p>
</footer>

riot.mount('main')

If I mount also nested component, it works, see here: https://plnkr.co/edit/UDkdZ55ynTYz9uxL如果我还安装了嵌套组件,则它可以工作,请参见此处: https : //plnkr.co/edit/UDkdZ55ynTYz9uxL

riot.mount('main')
riot.mount('footer')

What is the correct way to do this?这样做的正确方法是什么?

in riot you cannot use the same name of another existing tag, so, because footer is an existing tag you should change the name of "footer" component and it will work just fine!在 riot 中,您不能使用另一个现有标签的相同名称,因此,因为页脚是一个 现有标签,您应该更改“页脚”组件的名称,它会正常工作! ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM