Domanda

E 'possibile definire un catch-all percorso o un itinerario errore nella Sammy.js? So che posso associare a 'errore', ma se non ci sono le partite di percorso che non sembra essere attivato.

Grazie!

È stato utile?

Soluzione

According to the documentation for Sammy routes,

Paths can be defined as strings or regular expressions.

As such, it should be possible to create a route like this, at the end of your routes, that is a catch-all:

get(/.*/, function() { 
  ...
});

Altri suggerimenti

You should override the notFound function.

Like this:

var app = $.sammy('#app', function() {
  this.notFound = function(){
    // do something
  }
});

This is recommended by the author of Sammy.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top