我的代码:
var a = "1",
b = "hello",
c = { "100" : "some important data" },
d = {};
d[a]["greeting"] = b;
d[a]["data"] = c;
console.debug (d);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
未捕获的TypeError:无法设置未定义的属性'greeting'.
我正在尝试做一些类似于关联数组的事情.为什么这不起作用?
这是我的HTML代码片段:
<mat-card-content>
<div fxLayout="row" fxFlex="1 0 0">
<div fxLayout="column">First</div>
<div fxLayout="column" style="margin-left:auto">Second</div>
</div>
</mat-card-content>
Run Code Online (Sandbox Code Playgroud)
和CSS:
.mat-card-content {
color: rgba(0, 0, 0, 0.700);
}
Run Code Online (Sandbox Code Playgroud)
我需要在角度材料卡元素内实现柔性布局,以便两列能够响应并包含一些文本,如杂志中的内容:
现在我已经完成了 mat-card-header 并且它工作正常。任何建议将不胜感激。
我有可嵌套列表和复选框,我需要工作检查父复选框使所有子项检查并将子值保存到数组中.
当检查父级时,我已经弄清楚所有子复选框的检查?但我无法同时保存他们的价值观.
HTML
<ul>
<li class="main-parent">
<input class="main-checkbox" type="checkbox" value="id">
<ul>
<li>
<input class="sub-checkbox" type="checkbox" value="1">
</li>
<li>
<input class="sub-checkbox" type="checkbox" value="2">
</li>
<li>
<input class="sub-checkbox" type="checkbox" value="3">
</li>
</ul>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
JQuery的
$('input:checkbox').change(function () {
var array=[];
if(type === "main-checkbox") {
var parent = $(this).closest('.dd-item');
if('$(parent).find('.sub-checkbox').is(":checked")) {
array.push($(parent).find('.sub-checkbox').prop('checked',this.checked).val());
}
}
});
Run Code Online (Sandbox Code Playgroud)
这一个返回空数组,没有保存.有可能这样做吗?
我无法使用导入,因为我总是会遇到以下错误:
(function (exports, require, module, __filename, __dirname) { import { expect } from 'chai';
SyntaxError: Unexpected token import
Run Code Online (Sandbox Code Playgroud)
在我的文件中,index.test.ts我有这个:
import { expect } from 'chai';
describe('Hello function', () => {
it('should return hello world', () => {
const result = hello();
expect(result).to.equal('Hello World!');
});
});
Run Code Online (Sandbox Code Playgroud)
在我package.json有这个:
"scripts": {
"test": "mocha --reporter spec --compilers test/**/*.test.js",
Run Code Online (Sandbox Code Playgroud)
},
我的tsconfig.json:
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"lib": [
"dom",
"es2015"
],
"outDir": "dist",
"strict": false
}
} …Run Code Online (Sandbox Code Playgroud) 角度 4 的 d3.drag 出现问题。每当我拖动矩形对象时,它第一次移动得很好。释放鼠标并再次尝试拖动矩形后,它会返回到上一个事件,并且无法在可拖动对象上进行鼠标控制。请解决我的问题。
import { Component,Input, ElementRef, OnInit } from '@angular/core';
import * as d3 from 'd3';
interface LineData{
xVal: number,
yVal:number
}
@Component({
selector: 'app-line-chart',
template:'<svg height="500" width="500" ></svg>',
styleUrl: []
})
export class LineChartComponent implements OnInit {
@Input() data : LineData[];
private parentNativeElement : any;
constructor(private element:ElementRef) {
this.parentNativeElement = element.nativeElement;
}
ngOnInit() {
var width = 300;
var height = 300;
var margin = {top: 10, right: 10, bottom: 30, left: 10}
var x = …Run Code Online (Sandbox Code Playgroud) 我正在使用react-native-maps并且效果很好。但我有两个问题。
我可以使用 自动跟踪用户位置,followsUserLocation但是当我移动地图时,它不断将我拖回用户位置。我怎么能解决这个问题?
我想要刷新按钮,当用户按下按钮时,我希望我的地图视图跟随用户位置。
constructor() {
super();
this.state = {
followsUserLocation: true,
};
}
mapView() {
return(
<MapView style={styles.map}
showsUserLocation
followsUserLocation={this.state.followsUserLocation}
initialRegion={{
latitude: 37.523814,
longitude: 126.927494,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421}}/>
)
}
Run Code Online (Sandbox Code Playgroud)任何意见或建议将不胜感激!提前致谢!
这是我的JavaScript函数
function movements(remove) {
var op = remove ? 'remove' : 'add';
crossvent[op](documentElement, 'selectstart', preventGrabbed); // IE8
crossvent[op](documentElement, 'click', preventGrabbed);
} function move(value) {
Run Code Online (Sandbox Code Playgroud)
这就是所谓的
movements();
Run Code Online (Sandbox Code Playgroud)
您可以在jkanban.js文件中找到参考。
现在我必须将其更改为Typescript,并且在函数调用时遇到此错误,
Expected 1 arguments, but got 0
Run Code Online (Sandbox Code Playgroud)
我该如何解决打字稿中的问题?
我正在与服务人员合作在我的用户之间显示通知。在我的代码中我包含notificationclick事件。通过这次活动,我试图处理两个案例。第一种情况,如果在我的浏览器中打开了我的网站页面,请不要打开它,而是关注它。第二种情况,如果我的浏览器没有显示我的网站,请打开它并关注它。但我还没有成功...
这是我当前的代码:
self.addEventListener('notificationclick', function (e) {
console.log('notification was clicked')
var notification = e.notification;
var action = e.action;
if (action === 'close') {
notification.close();
} else {
// This looks to see if the current is already open and
// focuses if it is
e.waitUntil(
self.clients.matchAll().then(function(clientList) {
console.log(clientList)
if (clientList.length > 0) {
console.log(clientList[0])
return clientList[0].focus();
}
return self.clients.openWindow('/');
})
);
};
});
Run Code Online (Sandbox Code Playgroud) 我有两个变量来计算 clientHeight,除以 2 并加 44。它当前按预期工作,除非调整窗口大小,需要刷新页面才能重新计算 clientHeight。一旦刷新,它就会正确地重新定位 div。如何在调整窗口大小时重新计算每个窗口的 clientHeight ,以便不需要刷新页面即可再次运行脚本并获取新的高度?
这是基于滚动位置的动画的一部分。当您向下滚动页面时,div 会产生动画。
var triggerOffset = document.documentElement.clientHeight / 2 + 44;
var cardHeight = $('#card').outerHeight(true) / 2 + 22;
var duration = 1000;
var requestId = null;
var sceneStart;
if (window.matchMedia("(max-width: 1080px)").matches) {
sceneStart = 4000
} else {
sceneStart = 4000
}
console.log(sceneStart);
TweenLite.set(".contain", {
top: triggerOffset - cardHeight
});
TweenLite.set(".timeline-trigger", {
top: triggerOffset
});
TweenLite.set(".start-trigger", {
top: sceneStart
});
TweenLite.set(".end-trigger", {
top: sceneStart + duration
});
// SCROLL MAGIC!!!
var …Run Code Online (Sandbox Code Playgroud) 我正在尝试将app.component文件中的console.log数据作为我的服务文件.我没有定义.
这是我的代码
service.ts
getBillingCycles() {
return this.http.get('../../assets/download_1.json');
};
Run Code Online (Sandbox Code Playgroud)
app.component.ts
export class AppComponent implements OnInit{
title = 'ngMTN';
billing: any;
constructor(private http: HttpClient, private BillingCyclesService: BillingCyclesServiceService) { }
ngOnInit() {
this.getBillingCycles();
}
getBillingCycles() {
this.BillingCyclesService.getBillingCycles()
.subscribe(data => this.billing = data);
console.log(this.billing);
}
}
Run Code Online (Sandbox Code Playgroud) javascript ×7
angular ×3
html ×3
typescript ×3
css ×2
d3.js ×1
jquery ×1
node.js ×1
react-native ×1
workbox ×1