我正在尝试为两个因素的特定级别创建一个颜色列表。参数如下:
> df.coldata
Condition Tank
R235 Control T6
R236 LowExposure T6
R239 HighExposure T6
R241 Control T8
R242 LowExposure T8
R245 HighExposure T8
R247 Control T14_3
R248 LowExposure T14_3
R250 HighExposure T14_3
Run Code Online (Sandbox Code Playgroud)
由于我不想手动填写 Tank 编号或 Condition,我尝试使用分配的变量创建一个列表,如下所示:
### Specify colors ####
Tanks <- levels(df.coldata$Tank)
Conditions <- levels(df.coldata$Condition)
ann_colors <- list(
Condition = c(Conditions[1]="lightskyblue", # This doenst work ... BUGS here!!!
Conditions[3]="royalblue1",
Conditions[2]="navyblue"),
Tank = c(Tanks[1]="gray90",
Tanks[2]="gray65",
Tanks[3]="gray40")
)
Run Code Online (Sandbox Code Playgroud)
但这会产生一个错误告诉我:
Error: unexpected '=' in:
"ann_colors <- list(
Condition = c(Conditions[1]="
Run Code Online (Sandbox Code Playgroud)
当我运行代码时:
ann_colors …Run Code Online (Sandbox Code Playgroud) 我是 ReactJS 的新手。这是我的第一个 React 程序。实际上,这是一个动态页面,我正在使用运行良好的 API,但我想动态搜索。我尝试了一些教程,但它显示了一些错误。请解决问题。我的代码如下:
import React, {useState,useEffect} from 'react';
import './App.css';
function About() {
state ={
search : ""
}
useEffect(() => {
fetchItems();
}, []);
const [set, setItems] = useState([]);
const fetchItems = async () => {
const data = await fetch(
'http://www.ongccreditsociety.com/api/circular.php'
);
const set = await data.json();
console.log(set);
setItems(set);
};
onchange = e => {
this.setState({ search : e.target.value});
}
render(){
const {search} = this.state;
const filter = set.filter( country =>{
return country.Description.toLowercase().indexOf(search.toLowercase() ) != …Run Code Online (Sandbox Code Playgroud) Node.js / JavaScript控制台中此评估背后的任何解释:
> a:1
1
Run Code Online (Sandbox Code Playgroud)
尝试分配给变量引发错误:
> x = a:1
Thrown:
x = a:1
^
SyntaxError: Unexpected token :
Run Code Online (Sandbox Code Playgroud)
就像只留a:在JS控制台中一样:
a:
VM138:3 Uncaught SyntaxError: Unexpected token }(…)
Run Code Online (Sandbox Code Playgroud)
在Node.js REPL中:
> a:
... 3
3
Run Code Online (Sandbox Code Playgroud) 我的应用程序每次到达此行时都会崩溃:
const {name, price} = req.query;
^
Run Code Online (Sandbox Code Playgroud)
似乎无法找到确切的答案..错误日志
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:140:18)
at node.js:1043:3
Run Code Online (Sandbox Code Playgroud)
背景:
app.get('/products/add' , (req, res) => {
const {name, price} = req.query;
const INSERT_PRODUCTS_QUERY = `INSERT INTO products (name, price) VALUES ('${ name }', ${ price })`;
connection.query(INSERT_PRODUCTS_QUERY, (err,results) => {
if(err)
{
return res.send(err);
}
else
{
return res.send('succesfully added product');
}
});
});
Run Code Online (Sandbox Code Playgroud)