(我使用的是Visual Studio 2017)
我开始了一个小型的控制台应用 一个Discord C#bot.所以我总是用Visual Studio启动这个程序.完成后,我想将.exe文件放在服务器上,以保持这个机器人整天保持在线状态.
在目录中,没有.exe文件.
所以我再次启动了应用程序,看到这个控制台是从不同的路径打开的
"C:\ Program Files\dotnet",此.exe称为"dotnet.exe"
当我想手动启动这个.exe文件时,它立即关闭(可能是因为缺少Console.ReadLine();
我不知道的代码行).
有人能告诉我,在Visual Studios设置中要更改什么,在我的控制台应用程序的正确目录中有一个.exe文件?
附图显示了我的bin目录,通常应该是.exe文件.有一个.dll文件,但我需要.exe ..
我想从我的数据库中获取一些数据。例子:
getCarIds: function (callback) {
db.query("SELECT Id FROM Cars;",
function (err, result) {
if (err) throw err;
result = JSON.stringify(result);
var cars = [];
for (var i = 0; i < result.length; i++) {
var currentCar = result[i];
var carId = currentCar.id;
cars.push(carId);
}
callback(cars);
});
}
Run Code Online (Sandbox Code Playgroud)
我想将所有 id 存储到一个数组中。喜欢
cars = [1,2,3,4,5];
Run Code Online (Sandbox Code Playgroud)
结果返回这个
[ RowDataPacket { Id: '1' },
RowDataPacket { Id: '2' },
RowDataPacket { Id: '3' } ]
Run Code Online (Sandbox Code Playgroud)
所以我尝试通过写作来转换它
result = JSON.stringify(result);
Run Code Online (Sandbox Code Playgroud)
这还给我
[{"Id":"1"},{"Id":"2"},{"Id":"3"}]
Run Code Online (Sandbox Code Playgroud)
当我想通过写入访问此对象时
result[0]
我得到 …
在选择一个角色时,我目前有一个基类
abstract class CharacterClass
{
public abstract void AbilityOne();
public abstract void AbilityTwo();
}
Run Code Online (Sandbox Code Playgroud)
我的角色来自这个班级
class Warrior : CharacterClass
{
public override void AbilityOne()
{
// implement ability one here
}
public override void AbilityTwo()
{
// implement ability two here
}
}
Run Code Online (Sandbox Code Playgroud)
最后,我使用此代码选择战士
CharacterClass selectedClass = new Warrior(); // start the game as a Warrior
Run Code Online (Sandbox Code Playgroud)
所以这种方式非常好.但是当谈到冷却等时,我想保持干净的代码,所以我想创建一个Ability
类.
我抽象的父类
abstract class CharacterClass
{
public Ability AbilityOne { get; set; }
public Ability AbilityTwo { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
战士班 …
我有一个简单的应用程序,应该输出少量内容。我使用NodeJs,Express和Pug。
const pug = require('pug');
const express = require('express');
const app = express();
const indexFile = 'index'; // the file to load
app.set('view engine', 'pug'); // use pug
app.get('/', function (req, res) {
res.render(indexFile, {content: 7}); // load the file and set the variable to 7
});
app.listen(8888, function () {
console.log('Server running on port 8888');
});
Run Code Online (Sandbox Code Playgroud)
还有我的帕格文件/ HTML
doctype html
link(rel='stylesheet', href='../CSS/requirements.css')
script(src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js')
body
p = content
Run Code Online (Sandbox Code Playgroud)
启动服务器时,我收到此错误消息
Error: C:\Users\mah\Desktop\Test\views\index.pug:2:1
1| doctype html
> 2| link(rel='stylesheet', href='../CSS/requirements.css') …
Run Code Online (Sandbox Code Playgroud) 我有两个图像在DOM元素周围移动.但是它们的旋转是错误的,并且运动不顺畅.
我的小提琴
#mainPage {
width: 400px;
height: 165px;
margin: 10% auto;
}
#mainPage>p {
text-align: center;
}
.bicycle {
width: 48px;
height: 30px;
background: red;
}
#bicycleOriginal {
animation: moveBicycleOriginal 20s infinite;
}
#bicycleFlipped {
animation: moveBicycleFlipped 20s infinite;
}
#mainTxt {
letter-spacing: 7px;
font-size: 30px;
margin-bottom: 30px;
}
@keyframes moveBicycleOriginal {
from {
transform: translate(0, 0);
}
1% {
transform: translate(0, 0) rotate(0deg);
}
25% {
transform: translate(350px, 0);
}
26% {
transform: translate(350px, 0) rotate(90deg);
}
50% { …
Run Code Online (Sandbox Code Playgroud)我需要一些有关 WinForms 响应式表单的帮助。我在位置 xy 有一个复选框。当我将表单调整为较小的尺寸时,此复选框应移至左侧,更靠近其他元素。
你可以在我制作的图片上看到它。我不知道,我必须在那里更改哪个属性才能实现这一点。要移动的复选框由红色框标记。
当我放大表单时,这个元素必须保持在它的默认位置。当我减少它时,复选框必须向左移动。当我再次放大它时,复选框必须移回其默认位置。
我想在 Unity 中创建一些萤火虫。我想增加光强度,然后等待几秒钟,然后在 Unity 中减少它。当它们生成时,我希望它们增加光强度,等待几秒钟,然后淡出。我怎样才能以干净的方式创建这个“过程”?
private Light pointLight; // The light component of the firefly
private float minLuminosity = 0; // min intensity
private float maxLuminosity = 1; // max intensity
private float luminositySteps = 0.005f; // factor when increasing / decreasing
private float shineDuration = 3; // wait 3 seconds when faded in
private void Start()
{
pointLight = GetComponent<Light>();
pointLight.intensity = Random.Range(minLuminosity, maxLuminosity); // start with a random intensity
StartCoroutine(ChangeIntensity()); // start the process
}
private IEnumerator ChangeIntensity() …
Run Code Online (Sandbox Code Playgroud) 我已经动态创建了div。对于一些测试,我选择 30 个 div。
每个 div 底部都有一个按钮栏。我只想在悬停 div 容器时显示此栏。
当隐藏这些元素时,div 会变小/缩小。我想保持更大的尺寸,因此仅隐藏按钮,但容器保持其尺寸。
离开 div 时,只有按钮应该消失。
#wrapper{
padding: 50px;
background-color: red;
}
#content{
color: white;
padding: 10px;
font-size: 20px;
}
#wrapper:hover .btn{
display:block;
}
.btn{
display:none;
}
Run Code Online (Sandbox Code Playgroud)
<div id="wrapper">
<div id="content">
content
</div>
<div>
<button class="btn">
Button 1
</button>
<button class="btn">
Button 2
</button>
<button class="btn">
Button 3
</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
server.js
使用主体解析器中间件,车把和快递
路线
module.exports = function (app) {
app.post('/questionnaire/submit', function (req, res) { // Ajax Call
var data = JSON.parse(req.body);
res.send({});
});
};
Run Code Online (Sandbox Code Playgroud)
客户
function submitData() { // Send a data object to the server
$.ajax({
type: 'POST',
url: '/questionnaire/submit',
dataType: "json",
data: JSON.stringify({
satisfactory: "text 1",
improvement: "text 2",
rating: 0.7
})
}).done(function () {
$(location).attr('href', '/sendOff');
}).fail(function () {
});
}
Run Code Online (Sandbox Code Playgroud)
登录时,req.body
我得到一个JSON字符串
{'{“满意”:“文本1”,“改进”:“文本2”,“等级”:0.7}':“”}
我尝试将此字符串解析为一个对象。这样做时,我会收到此错误消息
Run Code Online (Sandbox Code Playgroud)TypeError: Cannot convert object to primitive value at JSON.parse (<anonymous>) at C:\Users\mah\Desktop\FeedbackTool\Server\Routes\questionnaire.js:12:25 …
我想用 javascript 创建一个 toast 通知。当用户做得很好时,应该会出现一个消息框(toast),并显示绿色和文本“成功”或其他内容。
如果没有,颜色为红色,文本应为“失败”。这个 div 应该从屏幕中心的顶部滑动,停留 3 秒,之后,它应该从 DOM 中删除。
我在这里找到了这个,用来创建我的 div
CreateToast(isValid) { // Toast notification
var toastDiv = document.createElement("div");
var toastMessage;
var foreColor;
var backgroundColor;
var borderColor;
if (!isValid) {
toastMessage = "Failure";
foreColor = "";
backgroundColor = "";
borderColor = "";
} else {
toastMessage = "Success";
foreColor = "";
backgroundColor = "";
borderColor = "";
}
toastDiv.innerHTML = toastMessage;
document.body.appendChild(toastDiv);
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何设置其余部分。将其放置在哪里,如何从顶部中心滑落等。
我知道,我可以使用删除 div
toastDiv.remove(); // Delete the element from the DOM
Run Code Online (Sandbox Code Playgroud)
但是“3秒后销毁”怎么用呢?
我目前的div看起来像这样:
这应该是这样的:
在我的css文件中,我有这个代码:
.noteWrapperDiv { /* the container div */
width: 100%;
height: 50px;
background-color: #21252B;
border-width: 2px;
border-style: solid;
border-radius: 5px;
border-color: #9DA5B4;
}
.noteContentDiv { /* the first inner div */
color: #9DA5B4;
float: left;
}
.noteButtonBarDiv { /* the second inner div */
float: right;
Run Code Online (Sandbox Code Playgroud)
}
所以我的包装器中的两个div应该居中.我尝试左右浮动,顶部:50%,但它没有集中..