Using React-Router to link within a page

时间:2015-07-28 23:57:19

标签: javascript html reactjs react-router

I'm trying to make an anchor tag which will link to a location within the same page (like this)

However React-Router hijacks that, and and routes me to nothing, as I haven't established that link in the hierarchy. So it sends me to the root location of that name, instead of a location on the same page.

1 个答案:

答案 0 :(得分:1)

if i understand your question, you can use hashlocation instead of history location. like this

var BrowserWindow = require('browser-window')
var express = require('express');

var app = express();
app.use(express.static(__dirname));

app.get('/', function (req, res) {
  res.send('Hello World!');
});






var server = app.listen(3000, function () {
  var host = server.address().address;
  var port = server.address().port;

  console.log('Example app listening at http://%s:%s', host, port);
});




app.on('ready', function() {
  var mainWindow = new BrowserWindow({
    width: 800,
    height: 600
  })
  mainWindow.loadUrl('http://localhost:3000')
})