2016-07-17 4 views
-2

ich mit NodeJS verwenden Bootstrap möchten, drücken wieVerwendung app.use() anstelle von Script-Tag in Knoten ausdrücken

app.use('/scripts', express.static(__dirname + '/node_modules/jquery/dist/js/jquery.min.js')); 
 
app.use('/link', express.static(__dirname + '/node_modules/bootstrap/dist/css/bootstrap.min.css')); 
 
app.use('/scripts', express.static(__dirname + '/node_modules/bootstrap/dist/js/bootstrap.min.js'));

statt

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> 
 
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
verwenden

Bitte helfen Sie mir, danke!

+1

Uhm ist, was? 'app.use' hat wirklich nichts mit Skript-Tags im Browser, es sei denn, Sie erstellen eine Middleware, die das tatsächlich tut? – adeneo

+0

Ich weiß nicht, wie man ersetzt, bitte zeigen Sie mir einen Weg – Cver

Antwort

0

Ich habe diesen Code verwendet, und es gelang ihm, aber nicht sicher, ob das die beste

app.use('/jquery.min.js', express.static(__dirname + '/node_modules/jquery/dist/jquery.min.js')); 
 
app.use('/bootstrap.min.css', express.static(__dirname + '/node_modules/bootstrap/dist/css/bootstrap.min.css')); 
 
app.use('/bootstrap.min.js', express.static(__dirname + '/node_modules/bootstrap/dist/js/bootstrap.min.js'));
<script src="/jquery.min.js"></script> 
 
    <link rel="stylesheet" href="/bootstrap.min.css"> 
 
    <script src="/bootstrap.min.js"></script>

Verwandte Themen