小编Nag*_*hab的帖子

Javascript日期未定义错误

这是我的代码,我得到"Uncaught TypeError:undefined不是函数"我做错了什么?

var myDate = new Date().setDate(17);
document.getElementById("result").innerHTML = myDate.getDate();
Run Code Online (Sandbox Code Playgroud)

javascript

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

访问容器功能的最佳设计方法

我是SLIM3的新手,并按照教程在容器中获取我想从代码中的任何位置访问的一些函数.所以这是我的index.php文件,我在那里推荐一切:

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

// Require for loading the vendor libraries installed by composer
require 'vendor/autoload.php';


$config['displayErrorDetails'] = true;
$config['addContentLengthHeader'] = false;

$app = new \Slim\App(["settings" => $config]);
$container = $app->getContainer();

// Monolog initalisation. To use it write: $this->logger->addInfo("what you want to write here");
$container['logger'] = function($c) {
    $logger = new \Monolog\Logger('eq_logger');
    $file_handler = new \Monolog\Handler\StreamHandler("logs/app.log");
    $logger->pushHandler($file_handler);
    return $logger;
};

// Database connections
$container['dbteacher'] = function ($c) {
    $pdo = new PDO($_SERVER['PGSQL_CONNECTION_STR']); …
Run Code Online (Sandbox Code Playgroud)

php slim-3

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

git忽略文件而不是具有相同名称的文件夹

我的代码结构是:

.gitignore
my-service << this is a file without an extention
charts
| my-service << this is a folder
| | file1
| | file2
Run Code Online (Sandbox Code Playgroud)

当我在我的gitignore中写道时,my-service它忽略了my-service文件和my-service文件夹.如何只忽略根目录中的文件,而不是子目录?

git gitignore

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

在通道上迭代时出现错误“范围内的变量过多”

我在这里迷失了方向,我试图让一个goroutine添加到数组中,并从中读取另一个goroutine,我怀疑它与下面的内容有些相似,但我需要尝试使用wait() 。

但是,我遇到了错误prog.go:19:14: too many variables in range,第19行是for _, v := range c {我在网上找不到答案,我在做什么或不做什么?

package main

import (
    "fmt"
    //"time"
    "sync"
)

func hello(wg *sync.WaitGroup, s []int, c chan int) {
    for _, v := range s {
        c <- v
    }
    fmt.Println("Finished adding to channel")
    wg.Done()
}

func hello2(wg *sync.WaitGroup, c chan int) {
    fmt.Println("Channel",c)
    for _, v := range c {
        fmt.Println("Received",v)   
    }
    fmt.Println("Finished taking from channel")
    wg.Done()
}

func main() {
    s := …
Run Code Online (Sandbox Code Playgroud)

for-loop channel go

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

标签 统计

channel ×1

for-loop ×1

git ×1

gitignore ×1

go ×1

javascript ×1

php ×1

slim-3 ×1