我刚开始学习角度,我试图创建一个简单的仪表板.
我创建了2个组件,DashboardComponent和SidebarComponent.
仪表板加载正常,但是当我加载SidebarComponent时我在浏览器上遇到错误"为组件指定的模板SidebarComponent不是字符串"
SidebarComponent:
import { Component } from '@angular/core';
@Component({
selector: 'sidebar-component',
templateUrl: './sidebar.component.ts',
styleUrls: ['./sidebar.component.scss']
})
export class SidebarComponent {}
Run Code Online (Sandbox Code Playgroud)
App.module
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { SidebarComponent } from './sidebar/sidebar.component';
@NgModule({
declarations: [
AppComponent,
DashboardComponent,
SidebarComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
它们都加载到app.component中
<sidebar-component></sidebar-component>
<dashboard></dashboard>
Run Code Online (Sandbox Code Playgroud) 我有一个下拉功能,只需点击这个div即可调用
<div (click)="toggleDropdown($event)" data-id="userDropdown">
Username <i class="mdi mdi-chevron-down"></i>
</div>
Run Code Online (Sandbox Code Playgroud)
但是当我单击<i>元素时,不会触发click事件
toggleDropdown($event) {
const id = $event.target;
document.querySelector('[data-drop=' + id.getAttribute('data-id') + ']').classList.toggle('active');
}
Run Code Online (Sandbox Code Playgroud)
无论如何,我可以让孩子点击事件触发父母一个?
我如何在指针事件无div上触发mousemove事件,我无法编辑页面的html,只能编辑javascript(银行)
<h1>title</h1>
<div class="wrapper">
<h3>element 1</h3>
<h3>element 2</h3>
</div>
Run Code Online (Sandbox Code Playgroud)
该脚本当前仅触发主体作为目标,而不是元素
document.body.addEventListener("mousemove", function(e) {
console.log(e.target)
})
Run Code Online (Sandbox Code Playgroud)
我试图在标签内并排对齐两个社交按钮
文本对齐:居中不适用于按钮,也不浮动:左或浮动:右
jsfiddle链接http://jsfiddle.net/htajL17y/
HTML:
<!-- footer area -->
<footer>
<div id="colophon" class="wrapper clearfix">
COPYRIGHT 2014
<br>
Medialock Inc.
</div>
<div class="social-fb">
<img src="http://i.imgur.com/c6h4Mw6.png"/ >
<h3>
facebook.com/medialock
</h3>
</div>
<div class="social-tw">
<img src="http://i.imgur.com/pHQnY64.png"/ >
<h3>
twitter.com/medialock
</h3>
</div>
</footer><!-- #end footer -->
Run Code Online (Sandbox Code Playgroud)
CSS:
/*FOOTER*/
footer{
background: #333;
color: #ccc;
text-align: center;
float: center;
padding: 20px 0;
}
footer ul{
margin:0 0 0 8%;
padding:0;
}
/* Footer social links */
.social-fb {
width: 400px;
padding: 20px; …Run Code Online (Sandbox Code Playgroud) 无论如何,您可以在 Angular4 的样式绑定目标中进行计算吗?
我试过了
[style.width]="{{1+1}}"
[style.width]="{{1+1}}px"
[style.width]="{{1px+1px}}"
Run Code Online (Sandbox Code Playgroud) 我一直在尝试读取 google colab 中的文件,它应该将文件读取为简单的 JSON,但我什至无法在json.dumps(file)不出现 100 个错误的情况下执行
上传文件:
import json
import csv
from google.colab import files
uploaded = files.upload()
Run Code Online (Sandbox Code Playgroud)
打印作品,显示文件内容:
print(uploaded)
data = json.dumps(uploaded)
Run Code Online (Sandbox Code Playgroud)
但当我Object of type 'bytes' is not JSON serializable尝试做时我得到json.dumps(uploaded)
该文件不应该被读取为json和 notbytes吗?在其他一些情况下,我测试它也读作dictionary
JSON 文件:
[
{
"type": "message",
"subtype": "channel_join",
"ts": "123",
"user": "DWADAWD",
"text": "<@DWADAWD> has joined the channel"
},
{
"type": "message",
"subtype": "channel_join",
"ts": "123",
"user": "DWADAWD",
"text": "<@DWADAWD> has joined the channel"
},
{ …Run Code Online (Sandbox Code Playgroud) 我正在为分类广告网站制作 chrome 扩展程序。使用 chrome 扩展程序,用户将能够从他们观看的类别/搜索查询中获取最新列表。
我已经在使用 websocket 服务器向用户发送通知,但是这样我必须始终为每个用户打开一个套接字连接。
我的第二种方法是使用Firebase,但这只会在用户单击图标时运行通知(如我所见),我宁愿从我的服务器完成此操作
__
是否有其他可能的解决方案可以在用户不点击图标的情况下向 Chrome 扩展程序发送通知?
google-chrome websocket google-chrome-extension firebase-cloud-messaging
查询数据库时如何检查@azure/cosmos sdk中的参数是否为空?
我尝试过 IS_NULL 或 IS_EMPTY,要么会破坏查询:
await container.items
.query({
query: `
SELECT * from company
WHERE company.location = @location
AND (@dateFrom IS NULL OR company.createdAt >= @dateFrom)
AND (@dateTo IS NULL OR company.createdAt < @dateTo)
ORDER BY company.createdAt DESC
`,
parameters: [
{ name: "@location", value: "Germany" },
{ name: "@dateFrom", value: new Date().setFullYear(new Date().getFullYear() - 5)},
{ name: "@dateTo", value: new Date() },
]
})
.fetchAll();
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Message: {\"errors\":[{\"severity\":\"Error\",\"location\":{\"start\":243,\"end\":245},\"code\":\"SC1001\",\"message\":\"Syntax error, incorrect syntax near 'IS'.\"}]}
Run Code Online (Sandbox Code Playgroud) So I know that we can have multiple event handlers on the .on() method
$(document).on({
'click': function (e) {
// function
},
'hover': function (e) {
// function
}
});
Run Code Online (Sandbox Code Playgroud)
but is there anyway we can add multiple selectors to each event handler?
like this:
$(document).on('click', '#foo, .foo', function () {
// function
});
Run Code Online (Sandbox Code Playgroud)
but with multiple .on() methods:
$(document).on({
'click', '#foo': function (e) {
// doesn't work :(
},
'hover', '.foo': function (e) {
// doesn't work :(
} …Run Code Online (Sandbox Code Playgroud) 我有这个功能组件,它在将数据推送到数组时不会更新:
const Experience = (props) => {
let experience = [{
from:"",
to:"",
employer_name:"",
employer_number:""
}];
function addExperience() {
experience = [...experience, {
from:"",
to:"",
employer_name:"",
employer_number:"",
}];
}
return (
<>
{experience.map((val, idx) => {
let id = `exp-id-${idx}`
return(
<div key={idx} id={id}>
...
</div>
)
})}
<button onClick={addExperience}>Add experience</button>
</>
)
}
Run Code Online (Sandbox Code Playgroud)
单击添加体验时,映射未更新,有什么帮助吗?