RIOT js使用{}定义表达式。RIOT js允许以下类型的表达式。
<customTag> <h1>{title}</h1> <script> this.title = "Welcome to web176.COM"; </script> </customTag>
<customTag> <h2>{val * 5}</h2> <script> this.val = 4; </script> </customTag>
以下是上述概念的完整示例。
<customTag> <h1>{title}</h1> <h2>{val * 5}</h2> <h2>{opts.color}</h2> <script> this.title = "Welcome to web176.COM"; this.val = 4; </script> </customTag>
<!DOCTYPE html> <html> <head> <script src = "https://cdnjs.cloudflare.com/ajax/libs/riot/3.13.2/riot+compiler.min.js"></script> </head> <body> <customTag color="red"></customTag> <script src = "customTag.tag" type = "riot/tag"></script> <script> riot.mount("customTag"); </script> </body> </html>
这将产生以下结果: