小编Voi*_*ips的帖子

实时服务器未加载 css 文件

我有一个与我的 html 文件链接的 css 文件。通过实时服务器加载 html 文件时,我的 css 不起作用。

直接通过浏览器打开 html 文件时,css 工作正常。我的 css 文件位于 html 文件所在的目录之外。当我的 npm 脚本使用 live-server 作为 npm start 时,没有任何参数,它只显示我的工作区的所有文件,如果我点击我的 html 文件所在的目录,css 将起作用。但是如果我添加 html 文件作为 live-server 的参数,它只会加载 html 文件而没有任何 css 更改。

html:

<link rel='stylesheet' type='text/css' href='../styles.css'>
Run Code Online (Sandbox Code Playgroud)

包.json:

"start": "live-server home/index.html"
Run Code Online (Sandbox Code Playgroud)

或者

"start": "live-server home"
Run Code Online (Sandbox Code Playgroud)

或者

"start": "live-server home/index.html && styles.css"
Run Code Online (Sandbox Code Playgroud)

都有相同的结果。仅有的

"start": "live-server"
Run Code Online (Sandbox Code Playgroud)

works,它显示浏览器上的工作目录。我单击主目录,然后使用 css 加载 html 文件。

从终端输入 npm start 时,我的 html 文件可以在浏览器上正常加载,但由于某种原因链接的 css 文件没有加载。css 链接代码应该没问题,因为它在直接从浏览器打开时可以正常工作。css文件需要在同一个目录下吗?

html css npm package.json npm-live-server

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

每次调用函数时随机数都相同

每次我运行程序时,这些数字都是随机的,但在同一次运行中它们保持不变。我希望每次调用函数时数字都是随机的。我确实在 main() 中播种了生成器。

    std::random_device device;
    std::mt19937 generator(device());
Run Code Online (Sandbox Code Playgroud)

我的功能

void takeAssignment(std::vector<Student> &students,
                    const int min, const int max,
                    std::mt19937 e)
{
    std::uniform_int_distribution<int> dist(min, max);
    // all students take the assignment
    for (auto &s : students)
    {
        // random performance
        int score{dist(e)};
        s.addScore(score, max);
        std::cout << s.getName() << "'s score: " << score << std::endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

例如,每次在 min 为 0 和 max 为 10 的情况下调用该函数时,都会打印该函数的输出

Abril Soto's score: 1
Bailey Case's score: 9
Run Code Online (Sandbox Code Playgroud)

在那次运行期间。

将 dist 放入循环也不起作用,数字保持不变。

c++ random c++11

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

标签 统计

c++ ×1

c++11 ×1

css ×1

html ×1

npm ×1

npm-live-server ×1

package.json ×1

random ×1