我3天前在学校开始,我之前有一些C基础知识,所以这里的主要问题是语法(我认为).
目标是制作一个棋盘,8x8黑白方块,但我无法获得显示任何东西的代码.我错过了什么?
(html只有脚本src ="./ x.js"部分和"body"部分)
document.body.onload = addElement.innerHTML;
function addElement() {
var newTable = document.createElement("table");
for (var i = 1; i < 9; i++) {
var newTr = document.createElement('tr');
for (var j = 1; j < 9; j++) {
var newTd = document.createElement('td');
if (i % 2 == j % 2) {
newTd.className = "white";
} else {
newTd.className = "black";
}
newTr.appendChild(newTd);
}
newTable.appendChild(newTr);
}
document.body.appendChild(newTable);
document.getElementByClass("black").style.backgroundColor = "black";
document.getElementByClass("white").style.backgroundColor = "white";
document.getElementByTag("newTd").style.width = "25px";
document.getElementByTag("newTd").style.height = "25px";
}
Run Code Online (Sandbox Code Playgroud) 在 JavaScript 中,如何解引用函数返回的对象?
例如这个:
var tmp = getTextProperties();
font = tmp.font;
size = tmp.size;
color = tmp.color;
bold = tmp.bold;
italic = tmp.italic;
Run Code Online (Sandbox Code Playgroud)
PHP 具有 list() 构造,它执行类似的操作:
list($font, $size, $color, $bold, $italic) = getTextProperties();
Run Code Online (Sandbox Code Playgroud) 使用react-native-camera(RNCamera),当预览是窗口的全宽且完整预览可见时,我正在努力将相机预览的高度设置为正确。此问题假设设备始终处于纵向模式。
我的代码如下:
import React, { Component } from "react";
import { Dimensions, Button, View } from "react-native";
import { RNCamera } from "react-native-camera";
export default class CameraScreen extends Component {
static navigationOptions = {
header: null
};
render() {
return (
<View>
<RNCamera
ref={ref => {
this.camera = ref;
}}
style={{
width: Dimensions.get("window").width,
height: 400 // <-- need to know what this value actually is
}}
type={RNCamera.Constants.Type.back}
/>
<Button
title="This button should appear directly below the camera preview" …
Run Code Online (Sandbox Code Playgroud)