1
riot.route('/*', function(category) {
    riot.mount('#main', 'category-page', category)
})

When URL change, I want to get parameter as "category" and use it in <category-page>. I tried console.log(this.opts.category)in <category-page>, but what I got is undefined.

riot.route('/*', function(category) {
    riot.mount('#main', 'category-page', category)
    console.log(category)
})

When I code like above, console.log(category) works well. So I think do wrong with passing or getting parameter. I tried many case but I couldn't resolve it. Please help me with this problem.

Hiro
  • 47
  • 8

1 Answers1

0

According to riot.js router api documentation when calling riot.mount(selector, tagName, [opts]) you should pass an object that will be set to this.opts in your tag.

So your router code should look something like this:

riot.route('/*', function(category) {
    riot.mount('#main', 'category-page', {category: category})
});
  • Thank you for your help. It work well. I checked document and I think it says `riot.mount(selector, tagName, api)`. Anyway I really appreciate you!! – Hiro Nov 09 '16 at 04:46