小编Coc*_*Hot的帖子

Apache localhost/~username /不工作

更新:以下答案也适用于El Capitan.

对于刚刚开始的人,下面提到的文件位于/ etc/apache2下

对于下面的答案,还需要更改的文件是/etc/apache2/extra/httpd-userdir.conf

原文:

所以我最近刚升级到Mac OS X Yosemite,我需要再次设置我的Apache.我在/ user/kevin下创建一个文件夹"Sites",并将文件权限更改为777,并像以前一样取消注释/etc/apache2/httpd.conf中的php5module行.

localhost正在工作,但localhost/~kevin /给了我"在这台服务器上找不到请求的URL/~kevin /".

这是我的httpd.conf文件,以防任何人需要查看它.如果有人出错,我将不胜感激,如果有人可以发布他们的httpd.conf文件,那么我可以恢复它并再次执行.

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as …
Run Code Online (Sandbox Code Playgroud)

apache macos localhost osx-yosemite osx-elcapitan

95
推荐指数
4
解决办法
9万
查看次数

Jade:加载外部javascript和调用函数

我正在学习Express/Node/Jade,现在在Jade文件中我想要包含公共文件夹中的javascript文件,仅用于页面.例如,在jade文件中我输入:

script(src='/javascripts/test.js')
Run Code Online (Sandbox Code Playgroud)

和test.js里面我有一个功能

function check_test(){
    return "It's working!"
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试在Jade中调用函数

- var test_response = check_test()
Run Code Online (Sandbox Code Playgroud)

比我得到的错误说"undefined不是一个函数"而test.js根本没有加载.显然Jade没有加载文件,它们只转换成HTML代码.

我看了别人的问题,这是我能找到的最接近的问题,但它没有提供明确的答案. 在Jade中,如何在外部Javascript中调用函数

所以我的问题是:在这种情况下,我应该怎么做才能使它工作?

我不想在layout.js中加载文件,因为我只希望test.js只能被这个页面使用.

javascript node.js express pug

9
推荐指数
1
解决办法
9420
查看次数

使用Lodash合并复杂对象的数组

我是Lodash的新手并试图解决这个问题,但可以找到一个很好的方法来做到这一点.

我有一个从数据库返回的对象数组.数据结构如下:

var data = [{
    index: 1,
    Aoo: "a1",
    Boo: 'b2',
}, {
    index: 1,
    Aoo: "a2",
    Boo: 'b2',
}, {
    index: 2,
    Aoo: "a3",
    Boo: 'b3',
}];
Run Code Online (Sandbox Code Playgroud)

我想第一组由指数的对象,然后组属性"AOO"和"嘘",并把它称为数组属性param.

var result = [{
        index: 1,
        param: [{
            Aoo: 'A1',
            Boo: 'B1'
        },{
            Aoo: 'A2',
            Boo: 'B2',
        }]
    }, {
        index: 2,
        param: [{
            Aoo: 'A3',
            Boo: 'B3'
        }]
   }
]
Run Code Online (Sandbox Code Playgroud)

我可以手动完成,但我想充分利用Lodash的功能.现在我只知道我可以通过使用实现分组的第一步,_.groupBy('index')我仍然坚持下一步做什么.

javascript arrays json underscore.js lodash

2
推荐指数
1
解决办法
943
查看次数