RIOT js标记可以具有自己的样式,我们可以在标记内定义样式,这只会影响标记内的内容。我们还可以在标签中使用脚本来设置样式类。以下是如何实现RIOT标签样式的语法。
custom1Tag.tag
<custom1Tag> <h1>{title}</h1> <h2 class = "subTitleClass">{subTitle}</h2> <style> h1 { color: red; } .subHeader { color: green; } </style> <script> this.title = "Welcome to web176.COM"; this.subTitle = "Learning RIOT JS"; this.subTitleClass = "subHeader"; </script> </custom1Tag>
index.htm
<!DOCTYPE html> <html> <head> <script src = "https://cdnjs.cloudflare.com/ajax/libs/riot/3.13.2/riot+compiler.min.js"></script> </head> <body> <h1>Non RIOT Heading</h1> <custom1Tag></custom1Tag> <script src = "custom1Tag.tag" type = "riot/tag"></script> <script> riot.mount("custom1Tag"); </script> </body> </html>
预览效果:
作者:terry,如若转载,请注明出处:https://www.web176.com/riotjs/2199.html