简体   繁体   中英

RactiveJS bind multiple objects to template

Is it possible to bind more than one data object to a template? I find the single object philosophy a bit resistant to scalability. How can I add more observant data objects to a template without modifying the one already attached to it.

When you instanciate the ractive instance you could do something like this.

var r = new Ractive({data : {Object1:{},
                             Object2:{} } });

Then you can attached as many objects as you want.

Then you can scope this in your templates by doing

{{#Object1}}
<div>{{Prop1}}
{{/Obj1}}

{{#Object2}}
<div>{{PropForObject2}}
{{/Obj2}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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