我想设置反应路由器以用于子域.我不确定子域代理的逻辑应该在哪里.
我想要:
roxy.coolestblog.com/profile路由到coolestblog.com/roxy/profile
mohammed.coolestblog.com/profile路由到coolestblog.com/mohammed/profile
benben.coolestblog.com/profile路由到coolestblog.com/benben/profile
另一个用例:
en.coolestblog.com/some-article路由到coolestblog.com/en/some-article
fr.coolestblog.com/un-article路由到coolestblog.com/fr/un-article
es.coolestblog.com/una-article路由到coolestblog.com/es/una-article
我已经让它在没有子域的情况下工作了.
我怎样才能实现这一点,以便在客户端和服务器上都可以工作?
我正在为组件库创建文档.我想要1个html字符串,它可以生成页面上的组件和文档.
我想要的是:
是)我有的:
当我检查HTML时,我的按钮标签不存在.当我使用innerHTML时,它们被剥离了.
我的组件代码:
private flatButtons = `<div class="button-wrapper">
<my-button [type]="'default'" [raised]="false">Default</my-button>
</div>
<div class="button-wrapper">
<my-button [type]="'primary'" [raised]="false">Primary</my-button>
</div>
<div class="button-wrapper">
<my-button [type]="'success'" [raised]="false">Success</my-button>
</div>
<div class="button-wrapper">
<my-button [type]="'info'" [raised]="false">Info</my-button>
</div>
<div class="button-wrapper">
<my-button [type]="'warning'" [raised]="false">Warning</my-button>
</div>
<div class="button-wrapper">
<my-button [type]="'danger'" [raised]="false">Danger</my-button>
</div>`
constructor() {}
getCode() {
return html_beautify(this.flatButtons, this.options)
}
Run Code Online (Sandbox Code Playgroud)
我的HTML模板:
<div class="row">
<div class="col-sm-6 col-xs-12">
<mi-card title="Flat Buttons" baCardClass="with-scroll button-panel">
<div id="flatButtons" [innerHTML]="getCode()">
</div>
</mi-card>
</div>
<div class="col-sm-6 col-xs-12">
<pre>{{getCode()}}</pre>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在用纯C编写通用链表实现.
struct Node {
void *value;
struct Node *next;
};
struct LinkedList {
struct Node *start;
struct Node *end;
};
void LinkedList_new(struct LinkedList* llist) {
llist->start = 0;
llist->end = 0;
return;
}
void addNode( struct LinkedList *ll, void *_value ) {
if ( NULL == ll->start ) {
ll->start = (struct Node *) malloc( sizeof(struct Node) );
ll->end = ll->start;
} else {
ll->end->next = (struct Node *) malloc( sizeof(struct Node) );
ll->end = ll->end->next;
}
ll->end->value = _value; …Run Code Online (Sandbox Code Playgroud) 我正在编写一个API的包装器.api使用基本身份验证,然后POST请求需要PostForm值.我正在做这样的事情:
func NewFoo(name string) string {
client := &http.Client{}
URL := HOST + "foo/"
req, err := http.NewRequest("POST", URL, nil)
v := url.Values{}
v.Set("name", name)
req.Form = v
req.SetBasicAuth(EMAIL, PASSWORD)
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
bodyText, err := ioutil.ReadAll(resp.Body)
s := string(bodyText)
return s
}
Run Code Online (Sandbox Code Playgroud)
我有一个类似的,没有表单值的GET请求,它的工作原理.当我运行它时,它告诉我需要"名称"值.(所以它没有得到它)
有什么理由不起作用吗?
我在创建接口数组这个简单的任务时遇到了困难.这是我的代码,
var result float64
for i := 0; i < len(diff); i++ {
result += diff[i]
}
result = 1 / (1 + math.Sqrt(result))
id1 := user1.UserId
id2 := user2.UserId
user1.Similar[id2] = [2]interface{id2, result}
user2.Similar[id1] = [2]interface{id1, result}
Run Code Online (Sandbox Code Playgroud)
结果是一个浮点数,用户*.UserId是一个int.
我的错误信息是
syntax error: name list not allowed in interface type
我通过自制软件在我的Mac上下载了Rabbitmq。按照这些说明,我将sbin添加到path中,然后调用:
$ Rabbitmq服务器
并得到以下错误:
BOOT FAILED ===========
Error description:
{error,
{cannot_delete_plugins_expand_dir,
["/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost-plugins-expand",
{cannot_delete,
"/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost-plugins-expand/amqp_client-3.3.2/ebin/amqp_auth_mechanisms.beam",
eacces}]}}
Log files (may contain more information):
/usr/local/var/log/rabbitmq/rabbit@localhost.log
/usr/local/var/log/rabbitmq/rabbit@localhost-sasl.log
Stack trace:
[{rabbit_plugins,prepare_plugins,3,
[{file,"src/rabbit_plugins.erl"},{line,123}]},
{rabbit,'-boot/0-fun-1-',0,[{file,"src/rabbit.erl"},{line,332}]},
{rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,354}]},
{init,start_it,1,[]},
{init,start_em,1,[]}]
{"init terminating in do_boot",{rabbit,failure_during_boot,{error {cannot_delete_plugins_expand_dir,["/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost plugins-expand",{cannot_delete,"/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost-plugins-expand/amqp_client-3.3.2/ebin/amqp_auth_mechanisms.beam",eacces}]}}}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
Run Code Online (Sandbox Code Playgroud)
有人遇到过此错误吗?
我的客户端javascript将此JSON发布到服务器端:
{ username: 'hello', password: 'world' }
Run Code Online (Sandbox Code Playgroud)
我的Go服务器端代码:
type AuthJSON struct {
Username string `json:"username"`
Password string `json:"password"`
}
func AuthenticationHandler(w http.ResponseWriter, r *http.Request) {
// Parse the incoming user/pass from the request body
var body AuthJSON
err := json.NewDecoder(r.Body).Decode(&body)
log.Println(body)
log.Println(body.Username)
if err != nil {
log.Println(err)
panic(err)
}
...
}
Run Code Online (Sandbox Code Playgroud)
我的终端如下所示:
2013/07/31 20:26:53 { }
2013/07/31 20:26:53
2013/07/31 20:26:53 invalid character 'u' looking for beginning of value
2013/07/31 20:26:53 http: panic serving [::1]:58141: invalid character 'u' looking for …Run Code Online (Sandbox Code Playgroud) 我有一个深层嵌套的结构,它包含两个切片,如下所示:
package main
import "fmt"
type bar struct {
v1 []int
v2 []int
}
type foo struct{ bar bar }
type tar struct{ foo foo }
func main() {
f := &tar{foo: foo{bar: bar{v1: [2], v2: [3]}}}
fmt.Printf("Hello, playground %s", f)
}
Run Code Online (Sandbox Code Playgroud)
如何初始化两个切片?或者我如何使这个代码工作?
以下是Golang Play:http://play.golang.org/p/zLutROI4YH .
尝试在 go 中将 map[int] 解析为用户定义的结构:
这是数据模式。
type Recommendation struct {
Book int `json:"book"`
Score float64 `json:"score"`
}
Run Code Online (Sandbox Code Playgroud)
这是 json 编组:
ureco := make(map[int]data.Recommendation)
ureco, _ = reco.UserRunner()
json, _ := json.Marshal(ureco)
fmt.Println(json)
Run Code Online (Sandbox Code Playgroud)
其中 reco.UserRunner() 返回适当的结构类型。
这将打印一个空的 json 对象:
[]
Run Code Online (Sandbox Code Playgroud)
更新:
错误信息:
json: unsupported type: map[int]data.Recommendation
Run Code Online (Sandbox Code Playgroud)
那么我如何 json 结构映射?还是有替代方法?
我遇到的是节点:
var foo = bar || barfoofoo || foooobar;
Run Code Online (Sandbox Code Playgroud)
我怎么能在go中实现这个.
我正在使用freewall.http://vnjs.net/www/project/freewall/
试图在freewall术语中获得0保证金或0"gutter".这是我的HTML
<div class="free_wall">
<div class="brick"></div>
<div class="brick"></div>
<div class="brick"></div>
<div class="brick"></div>
<div class="brick"></div>
<div class="brick"></div>
<div class="brick"></div>
<div class="brick"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的css:
.free_wall {
width: 100%;
margin: 0;
padding: 0;
display: block;
}
.brick {
background: rgb(135, 199, 135);
width: 320px;
height: 320px;
margin: 0;
padding: 0;
}
Run Code Online (Sandbox Code Playgroud)
继承我的代码:
$(function() {
var wall = new freewall(".free_wall");
wall.fitZone();
//wall.refresh();
wall.reset({
selector: '.brick',
gutterY: 0,
gutterX: 0,
});
});
Run Code Online (Sandbox Code Playgroud) 我无法链接我的CSS样式表:
层次:
index.html的:
// index.html
<!DOCTYPE html>
<html>
<head>
<link href="css/index.css" type="text/css" rel="stylesheet">
</head>
<body>
<p class="blue">Hello</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
index.css:
// index.css
.blue {
font:blue;
font-size: 20px;
}
Run Code Online (Sandbox Code Playgroud)