我有一个使用Webpack的hello world Vue应用程序设置,并使初始的App组件正常工作并安装到正文.虽然在该App组件中我无法弄清楚如何使用我制作的更多组件.
main.js
import Vue from 'vue'
import App from './app.vue'
new Vue({
el: 'body',
components: { App }
})
Run Code Online (Sandbox Code Playgroud)
app.vue
<template>
<div class="message">{{ message }}</div>
</template>
<script>
export default {
data () {
return {
message: 'Hello World'
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我试过了
import TopBar from './top-bar.vue'
Run Code Online (Sandbox Code Playgroud)
在app.vue的main.js和script部分中,然后尝试使用
<top-bar></top-bar>
Run Code Online (Sandbox Code Playgroud)
没有运气.
我想我错过了如何正确注册组件,例如在Vue文档中:
Vue.component('top-bar', TopBar);
Run Code Online (Sandbox Code Playgroud)
但我认为在使用webpack和vue-loader时我需要做一些不同的事情.
我有一个指向成员函数的指针列表,但我很难尝试调用这些函数...什么是正确的语法?
typedef void (Box::*HitTest) (int x, int y, int w, int h);
for (std::list<HitTest>::const_iterator i = hitTestList.begin(); i != hitTestList.end(); ++i)
{
HitTest h = *i;
(*h)(xPos, yPos, width, height);
}
Run Code Online (Sandbox Code Playgroud)
我也试图在这里添加成员函数
std::list<HitTest> list;
for (std::list<Box*>::const_iterator i = boxList.begin(); i != boxList.end(); ++i)
{
Box * box = *i;
list.push_back(&box->HitTest);
}
Run Code Online (Sandbox Code Playgroud) 嘿所以我有一个Junction表连接两个不相关的表.两张桌子都有ID.我需要ID使用WHERE不同的值从每个表中选择,例如我是这样看的:
INSERT INTO c (aID, bID)
VALUES (SELECT a.ID WHERE a.Name="Me", SELECT b.ID WHERE b.Class="Math");
Run Code Online (Sandbox Code Playgroud)
我见过的所有示例都使用了一个join语句,但这两个表都有一个共同的值,在这种情况下它们没有.
我有一个使用Webpack的Vue JS项目,需要导入Chart.js.我试过了
// import Chart from 'chart.js/Chart.min.js'
Run Code Online (Sandbox Code Playgroud)
这在尝试使用库时会出现js错误.
嘿伙计们我最近一直在使用c#和事件,但我刚开始创建自己的事件并使用它们.我对使用event关键字的原因感到有点困惑,我只使用了委托来获得相同的结果.
public partial class Form1 : Form
{
ServerConnection connection = new ServerConnection();
public Form1()
{
InitializeComponent();
connection.ref = new del(MethOne);
connection.ref += new del(MethTwo);
}
public void MethOne(object message)
{
MessageBox.Show((string)message);
}
public void MethTwo(object message)
{
MessageBox.Show((string)message);
}
}
public delegate void del(string message);
public class ServerConnection
{
private TcpListener tcpListener;
public del ref;
private List<NetworkStream> clientList = new List<NetworkStream>();
public ServerConnection()
{
this.tcpListener = new TcpListener(IPAddress.Any, 3000);
ThreadStart startListening = new ThreadStart(ListenForClients);
Thread startThread = new Thread(startListening); …Run Code Online (Sandbox Code Playgroud) 嘿所以我正在制作一个以字符串作为键和成员函数指针作为值的映射.我似乎无法弄清楚如何添加到地图,这似乎没有工作.
#include <iostream>
#include <map>
using namespace std;
typedef string(Test::*myFunc)(string);
typedef map<string, myFunc> MyMap;
class Test
{
private:
MyMap myMap;
public:
Test(void);
string TestFunc(string input);
};
#include "Test.h"
Test::Test(void)
{
myMap.insert("test", &TestFunc);
myMap["test"] = &TestFunc;
}
string Test::TestFunc(string input)
{
}
Run Code Online (Sandbox Code Playgroud) 使用Get-Process时,如何将字符串用作-Name?
$program = "MyProgram"
Get-Process $program
Run Code Online (Sandbox Code Playgroud)
代替
Get-Process -MyProgram
Run Code Online (Sandbox Code Playgroud) 如何将人类可读的字符串转换为bytearray并返回?
假设我有"Hello World"并想要一个bytearray然后从bytearray到同一个字符串?
嘿,我有这样的代码
public object RetrieveItemRun(int item)
{
if (dictionary.ContainsKey(item))
{
MessageBox.Show("Retrieving" + item.ToString());
}
return dictionary[item];
}
Run Code Online (Sandbox Code Playgroud)
当尝试获取0的键时它总是崩溃,消息框确实显示所以ContainsKey方法为真,但当我尝试从键中检索值时它崩溃说:
"给定的密钥不在字典中"
嘿所以我的HTML中有一个文本区域,每当我点击列表中的文件名时,它会将文件的内容放在该文本区域中,它可以很好地在文件之间来回点击.只要我在textarea中编辑某些内容,然后再尝试再次单击文件名,它就不会执行任何操作或更新该文本区域.
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
var currentFile;
$(document).ready(function()
{
var request = new XMLHttpRequest();
request.open("GET", "getFiles.php", false);
request.send();
var result = request.responseText;
$("#fileNames").html(request.responseText);
});
$(document).ready(function()
{
$("li").click(function()
{
currentFile = $(this).text();
$("#currentFile").text(currentFile);
var request = new XMLHttpRequest();
request.open("GET", "getFileContents.php?fileName="+currentFile, false);
request.send();
var result = request.responseText;
$("#fileContents").text(result);
});
});
function saveFile()
{
var request = new XMLHttpRequest();
var contents = $("#fileContents").text();
request.open("GET", "saveFile.php?fileName="+currentFile+"&fileContents="+contents, false);
request.send();
}
</script>
<style type="text/css">
ul.fileList li
{
background-color:blue;
}
#fileContents
{
resize: none; …Run Code Online (Sandbox Code Playgroud)