首页 \ 问答 \ 为什么我的快速应用程序中的导航栏上没有其他选项卡?(Why won't other tabs on my navbar apear in my express app?)

为什么我的快速应用程序中的导航栏上没有其他选项卡?(Why won't other tabs on my navbar apear in my express app?)

我正在尝试使用express和charlotte构建一个应用程序。 我正在使用ejs来渲染我的html文件。 我有一个针对css的twitter bootstrap。 出于某种原因:

<div class="navbar navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container">
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>
      <a class="brand" href="#"><img src="./img/MySpending.png"></a>
      <div class="nav-collapse">
        <ul class="nav">
      <li ><a href="./login.html">Log in/out</a></li>
          <li class="active"><a href="#">Daily</a></li>
      <li ><a href="./monthly.html">Monthly</a></li>
          <li ><a href="./yearly.html">Yearly</a></li>
        </ul>
      </div><!--/.nav-collapse -->
  <div class='navbar_form pull-right'>

      </div>
    </div>
  </div>

对我来说,好像我的html不会在快递中更新。

这是我的app.js快递如果有帮助:

var express = require('express');

var conf = require('./conf');

var everyauth = require('everyauth')
  , Promise = everyauth.Promise;

everyauth.debug = true;

var mongoose = require('mongoose')
  , Schema = mongoose.Schema
  , ObjectId = mongoose.SchemaTypes.ObjectId;

var UserSchema = new Schema({})
  , User;

var mongooseAuth = require('mongoose-auth');

var path = require('path');

UserSchema.plugin(mongooseAuth, {
    everymodule: {
      everyauth: {
          User: function () {
             return User;
          }
      }
    }
   , password: {
        loginWith: 'email'
        , extraParams: {
             phone: String
           , name: {
                first: String
               , last: String
             }
         }
      , everyauth: {
             getLoginPath: '/login'
          , postLoginPath: '/login'
          , loginView: 'login.jade'
          , getRegisterPath: '/register'
          , postRegisterPath: '/register'
          , registerView: 'register.jade'
          , loginSuccessRedirect: '/'
          , registerSuccessRedirect: '/'
        }
     }
   , google: {
       everyauth: {
           myHostname: 'http://localhost:3000'
         , appId: conf.google.clientId
         , appSecret: conf.google.clientSecret
         , redirectPath: '/'
         , scope: 'https://www.google.com/m8/feeds'
      }
    }
});
// Adds login: String

mongoose.model('User', UserSchema);

mongoose.connect('mongodb://localhost/mydb');

User = mongoose.model('User');

var app = express();/*express.createServer(
    express.bodyParser()
  , express.static(__dirname + "/public")
  , express.cookieParser()
  , express.session({ secret: 'esoognom'})
  , mongooseAuth.middleware()
);*/

app.configure( function () {
   app.set('views', __dirname + '/views');
   app.set('view engine', 'ejs');
   app.engine('html', require('ejs').renderFile);
   app.use(express.static(path.join(__dirname, 'public')));
});


app.get('/', function (req, res) {
   res.render('index.html');
});
app.get('/monthly', function (req, res) {
   res.render('monthly.html');
});
app.get('/yearly', function (req, res) {
   res.render('yearly.html');
});

/*app.get('/logout', function (req, res) {
     req.logout();
    res.redirect('/');
});*/

mongooseAuth.helpExpress(app);

app.listen(3000);

所以我不确定是什么让视图不再更新,因为它目前正在渲染旧版本,导航中只有一个选项卡。 任何有关这方面的帮助将不胜感激。


I'm trying to build an app using express and charlotte. I'm using ejs to render my html files. I have a twitter bootstrap for the css. For some reason this:

<div class="navbar navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container">
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>
      <a class="brand" href="#"><img src="./img/MySpending.png"></a>
      <div class="nav-collapse">
        <ul class="nav">
      <li ><a href="./login.html">Log in/out</a></li>
          <li class="active"><a href="#">Daily</a></li>
      <li ><a href="./monthly.html">Monthly</a></li>
          <li ><a href="./yearly.html">Yearly</a></li>
        </ul>
      </div><!--/.nav-collapse -->
  <div class='navbar_form pull-right'>

      </div>
    </div>
  </div>

To me it seems like my html won't update in express.

here's my app.js in express if that helps:

var express = require('express');

var conf = require('./conf');

var everyauth = require('everyauth')
  , Promise = everyauth.Promise;

everyauth.debug = true;

var mongoose = require('mongoose')
  , Schema = mongoose.Schema
  , ObjectId = mongoose.SchemaTypes.ObjectId;

var UserSchema = new Schema({})
  , User;

var mongooseAuth = require('mongoose-auth');

var path = require('path');

UserSchema.plugin(mongooseAuth, {
    everymodule: {
      everyauth: {
          User: function () {
             return User;
          }
      }
    }
   , password: {
        loginWith: 'email'
        , extraParams: {
             phone: String
           , name: {
                first: String
               , last: String
             }
         }
      , everyauth: {
             getLoginPath: '/login'
          , postLoginPath: '/login'
          , loginView: 'login.jade'
          , getRegisterPath: '/register'
          , postRegisterPath: '/register'
          , registerView: 'register.jade'
          , loginSuccessRedirect: '/'
          , registerSuccessRedirect: '/'
        }
     }
   , google: {
       everyauth: {
           myHostname: 'http://localhost:3000'
         , appId: conf.google.clientId
         , appSecret: conf.google.clientSecret
         , redirectPath: '/'
         , scope: 'https://www.google.com/m8/feeds'
      }
    }
});
// Adds login: String

mongoose.model('User', UserSchema);

mongoose.connect('mongodb://localhost/mydb');

User = mongoose.model('User');

var app = express();/*express.createServer(
    express.bodyParser()
  , express.static(__dirname + "/public")
  , express.cookieParser()
  , express.session({ secret: 'esoognom'})
  , mongooseAuth.middleware()
);*/

app.configure( function () {
   app.set('views', __dirname + '/views');
   app.set('view engine', 'ejs');
   app.engine('html', require('ejs').renderFile);
   app.use(express.static(path.join(__dirname, 'public')));
});


app.get('/', function (req, res) {
   res.render('index.html');
});
app.get('/monthly', function (req, res) {
   res.render('monthly.html');
});
app.get('/yearly', function (req, res) {
   res.render('yearly.html');
});

/*app.get('/logout', function (req, res) {
     req.logout();
    res.redirect('/');
});*/

mongooseAuth.helpExpress(app);

app.listen(3000);

So I'm not sure what's keeping the view from updating, because it currently is rendering an older version with only one tab in the nav. Any help with this would be greatly appreciated.


原文:https://stackoverflow.com/questions/17767421
更新时间:2024-05-20 17:05

最满意答案

试试这段代码:

import matplotlib.pyplot as pl
import numpy as np

x = np.linspace(1, 10)

def f(x):
    return np.sin(x) + np.random.normal(scale=0.1, size=len(x))

pl.plot(x, f(x))

它会给你一个带有一些噪音的正弦波:

带有噪音的正弦波

编辑:

似乎某种随机游走是您正在寻找的。 这个功能会为你做到这一点:

def f(x):
    y = 0
    result = []
    for _ in x:
        result.append(y)
        y += np.random.normal(scale=1)
    return np.array(result)

这是它的外观示例( x = np.linspace(0, 1000, 1000) ):

随机漫步

它不再是x的函数,因此代码应该被重构以生成带有n步骤的随机游走。 我会把它留给你:)

编辑2:

如果你想要一个更平滑的曲线,你可以应用一个运行平均值( 从这个问题中偷来 ):

def runningMean(x, N):
    return np.convolve(x, np.ones((N,))/N)[(N-1):]

pl.plot(x, runningMean(f(x), 10))

您使用的窗口越大( N参数),结果越平滑。

例:

随意漫步与奔跑的意思


Try this code:

import matplotlib.pyplot as pl
import numpy as np

x = np.linspace(1, 10)

def f(x):
    return np.sin(x) + np.random.normal(scale=0.1, size=len(x))

pl.plot(x, f(x))

It will give you a sin wave with some noise added to it:

sin wave with noise

Edit:

It seems like some kind of random walk is what you're looking for. This function will do that for you:

def f(x):
    y = 0
    result = []
    for _ in x:
        result.append(y)
        y += np.random.normal(scale=1)
    return np.array(result)

This is an example of what it can look like (with x = np.linspace(0, 1000, 1000)):

random walk

It's not a function of x any longer though, so the code should probably be refactored to generate a random walk with n steps instead. I'll leave that to you :)

Edit 2:

If you want a smoother curve, you can apply a running mean (stolen from this question):

def runningMean(x, N):
    return np.convolve(x, np.ones((N,))/N)[(N-1):]

pl.plot(x, runningMean(f(x), 10))

The bigger window (the N parameter) you use, the smoother the result.

Example:

random walk with running mean

相关问答

更多
  • for i in range(1,31): x=random.randint(0,600) y=random.randint(0,800) star( x ,y )
  • 你可以把你的许愿望墙分成一个一个可用于显示的小格子。 用随机数来生成,显示在哪个格子内。这样来保证对齐。 每个格子的坐标预先计算好,这样就可以对齐了。又可以达到随机显示位置的目的。
  • 在这个功能: uni_num <- function(k) { Random_Seed <- put_Seed(k) T_value <- T_val(Random_Seed) Random_Seed <- New_Random_Seed(T_value) uniform_num(0, 1, Random(Random_Seed)) } 赋值Random_Seed <-的目标 ...
  • 您不应该将rand用于与线程相关的伪随机生成。 该函数使用所有线程共有的共享状态。 这创建了由线程绘制的PRN之间的依赖关系,并且由于对状态的访问必须被互斥,所以大幅减慢。 POSIX系统上的替代品是nrand48和jrand48 ,它们接收一个状态(应该是线程特定的)作为它们的参数。 正如其他人所说的那样,仅仅用时间价值来培育这种状态并不是一个好主意,线程可能会在同一时间做到这一点。 You shouldn't use rand for pseudo random generation in connec ...
  • 试试这段代码: import matplotlib.pyplot as pl import numpy as np x = np.linspace(1, 10) def f(x): return np.sin(x) + np.random.normal(scale=0.1, size=len(x)) pl.plot(x, f(x)) 它会给你一个带有一些噪音的正弦波: 编辑: 似乎某种随机游走是您正在寻找的。 这个功能会为你做到这一点: def f(x): y = 0 res ...
  • int random = (int)(Math.random()*(x); 这设置random等于0和x - 1之间的任何整数。 int random = 1 + (int)(Math.random()*(x); 将整体表达式加1只是将其更改为1和x之间的任何整数。 (int)(Math.random()*((100-1)+1)) 是多余的,相当于 (int)(Math.random()*(100) 所以请注意: 1 + (int)(Math.random()*(x)返回1到x + 1的int 但 ...
  • # test.py import numpy as np import matplotlib.pyplot as plt N = 10**6 plt.hist(np.random.uniform(size=N) * np.random.uniform(size=N), bins=50, normed=True) plt.show() 运行python test.py会产生: # test.py import numpy as np import matplotlib.pyplot as plt N = ...
  • (define (random-element list) (list-ref list (random (length list)))) (define (random-element list) (list-ref list (random (length list))))
  • 是的,你可以,你可以实现自己的LCG号码生成器,但正如Sarnold所提到的,你需要在两次通话之间保持状态。 Yes you can, you can implement your own LCG number generator, but as Sarnold mentions you need to maintain state between calls.
  • y = new Random(); x = y.Range(0, 1); if (x == 0) { generateExample(); } else if (x == 1) { generateExample2(); } y = new Random(); x = y.Range(0, 1); if (x == 0) { generateExample(); } else if (x == 1) { generateExample2(); }

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)