Open timwis opened 8 years ago
Join the question.
I do it this way, and it works.
import {Router} from 'director'
class Routing {
constructor() {
let router = Router({
'/': this.index,
'/route/': this.route
});
router.init();
}
index() {
console.log('index')
}
route() {
console.log('route')
}
}
Try import { Router } from 'director/build/director';
Look into package.json
, you can see "main": "./lib/director"
, there is actually no init
method in lib/director
.
+1.查看代码后才知道是这么玩
I just ended up using sheet-router on the client and server-router on the server. Quite simple.
import { Router } from 'director';
// -> "TypeError: (intermediate value).configure(...).init is not a function"
import { Router } from 'director/build/director';
// No problems.
Hey folks, I've been trying to debug this for the past hour but have decided it may not be just me.
Yields the error
router.init is not a function
onindex.js:19
.The documentation isn't quite clear on whether
init()
is necessary, so I tried without that line and the error goes away but the router doesn't appear to have any effect (nothing is logged). I also tried withoutnew
, but it tells methis.configure is not a function
.I'm trying to use this within an electron app, which has native support for
require()
, though I can't imagine it's any different than using a bundler like browserify/webpack. Any advice on how to use this lib?