我试图使用Express在我的Node.js中放置一个选项卡面板,但是当我单击选项卡(例如常规)时,我无法更改文本。
我没有任何错误。
我不知道为什么它不起作用。我正在将PHP网站转换为Node.js Jade和Express。
这是我的代码:
玉档案:
block content
h1 Last News
section#page-title
h1.mainTitle
br
.tabbable
ul#myTab2.nav.nav-tabs.nav-justified
li.active
a(href='#All', data-toggle='tab')
| All
li
a(href='#Geral', data-toggle='tab')
| General
li
a(href='#Events', data-toggle='tab')
| Events
li
a(href='#Updates', data-toggle='tab')
| Updates
li
a(href='#Sales', data-toggle='tab')
| Sales
li
a(href='#Community', data-toggle='tab')
| Community
.tab-content
#All.tab-pane.fade.in.active
p
| Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth.
p
| Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
#Geral.tab-pane.fade
p
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo.
p
| Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth.
#Events.tab-pane.fade
p
| Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin.
p
| Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
和我的New.js:
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.render('news', { title: ' Last news' });
$(document).ready(function(){
$(".nav-tabs a").click(function(){
$(this).tab('show');
});
});
});
module.exports = router;
我在做什么错了?
答案 0 :(得分:0)
Node.js是服务器端,您无法从Express更新浏览器中网页的内容。使用Express,您只能响应数据请求。您将需要在Express应用程序中构建Routes API,以从数据存储中检索数据,以及在UI代码中通过AJAX调用收到请求时。