小编Mon*_*lis的帖子

url vs urlRoot有什么区别

我想知道使用url或有什么区别urlRoot.我已经阅读了文档(backbonejs.org/#Model-url),但我仍然觉得我缺乏这方面的知识,我想知道更多.你什么时候用url?而在另一个例子中你何时必须使用urlRoot

backbone.js marionette

21
推荐指数
1
解决办法
8946
查看次数

如何在mongoose中使变量成为唯一键?

例如,如果我有这个架构

var userSchema = mongoose.Schema({
    username: String,
    email: String,
    password: String,
    _todo: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Todo'}]
});
Run Code Online (Sandbox Code Playgroud)

我希望用户名是唯一的密钥,其他用户无法复制.我怎样才能做到这一点?

mongoose mongodb

4
推荐指数
2
解决办法
5521
查看次数

如何在exceljs中使用createAndFillWorkbook()?

我按照文档

var workbook = createAndFillWorkbook();
Run Code Online (Sandbox Code Playgroud)

我得到这个错误对象#没有方法'createAndFillWorkbook'

即使我已经需要exceljs了

var Excel = require("exceljs");
Run Code Online (Sandbox Code Playgroud)

我想要做的是创建一个报告,但我对文档感到困惑,因为它没有说明如何使用createAndFillWorkbook()方法,它只是在这里说它立即使用它.

我在文档中提到:https://github.com/guyonroche/exceljs#writing-xlsx

javascript exceljs

3
推荐指数
2
解决办法
7630
查看次数

第二次登录后Visualize.js身份验证错误

我有一个使用Visualize.js的网站,该网站具有简单的登录/注销功能。每次登录时,我都会调用该authenicateUser()函数并注销destroySession()。当我尝试登录然后注销然后再次登录时,当我尝试呈现现有报告时,出现此抛出的错误:

HTTP Status 401 - Full authentication is required to access this resource
Run Code Online (Sandbox Code Playgroud)

功能authenicateUser()destroySession()如下所示:

function authenticateUser () {
    var myConfig = {
        auth : {
            name     : "superuser",
            password : "superuser"
        }
    };
    visualize.config( myConfig );
}

function destroySession() {
    visualize( function ( v ) {
        // Logout form JRS and finish the session.
        v.logout().done( function () {
        } );
    } )
}
Run Code Online (Sandbox Code Playgroud)

我想指出的是,当我第一次登录我的帐户时,不会引发此错误,并且可以完美呈现报告。

为什么注销后又再次登录会发生这种情况?

jasper-reports visualize

3
推荐指数
1
解决办法
1239
查看次数

angular.js 中的 $window 在使用 $window.open 时抛出异常

我抛出这个错误:

Error: Error: [$parse:isecwindow] Referencing the Window in Angular expressions is disallowed!
Run Code Online (Sandbox Code Playgroud)

当我尝试在 angularjs 中使用 $window.open/window.open 时。

生成.html

<div class="print-report-footer" ng-show="vm.clicked">
    <button type="button" class="btn btn-primary" ng-click="vm.downloadFile('pdf')">PDF</button>
    <button type="button" class="btn btn-primary" ng-click="vm.downloadFile('xls')">XLS</button>
    <button type="button" class="btn btn-primary" ng-click="vm.downloadFile('csv')">CSV</button>
</div>
Run Code Online (Sandbox Code Playgroud)

生成.ctrl.js

    function downloadFile ( fileType ) {
        var path = '/images/reports/DistrictSchoolReport.' + fileType;
        return $window.open( path );
    }

    self.downloadFile   = downloadFile;
Run Code Online (Sandbox Code Playgroud)

这是我使用过的代码。我需要怎么做才能避免每次使用 $window.open 时抛出这个错误?

javascript angularjs

0
推荐指数
1
解决办法
913
查看次数