所以我在我的反应项目中使用 material-Ui,我想设置一个占位符,它与所选项目的唯一区别是颜色是灰色而不是黑色
<Select
name="answer"
value={values.answer}
onChange={handleChange}
onBlur={handleBlur}
displayEmpty
className={styles.selectEmpty}
>
<MenuItem
value=""
disabled
className={styles.selectPlaceholderText}
>
Answer
</MenuItem>
<MenuItem value={"1"}>1</MenuItem>
<MenuItem value={"2"}>2</MenuItem>
<MenuItem value={"3"}>3</MenuItem>
<MenuItem value={"4"}>4</MenuItem>
</Select>
Run Code Online (Sandbox Code Playgroud)
这种方法给了我非常接近我需要的东西,问题是:
selectPlaceholderText似乎不起作用。好的,这是我遇到这个问题的第三面墙,首先这是我的 axios 配置文件
import axios from "axios";
import { withRouter } from "react-router-dom";
const instance = axios.create({
baseURL: process.env.REACT_APP_API,
headers: {
"content-type": "application/json"
},
responseType: "json"
});
function pushToLogin() {
this.props.history.push("/");
}
function createAxiosResponseInterceptor(axiosInstance) {
const interceptor = axiosInstance.interceptors.response.use(
response => response,
error => {
// Reject promise if usual error
console.log(error);
if (error.response.status !== 401) {
return Promise.reject(error);
}
/*
* When response code is 401, try to refresh the token.
* Eject the interceptor so it doesn't loop …Run Code Online (Sandbox Code Playgroud) 假设我有这种格式的元素列表(U"NAME",I"Item Name",INT_HERE)我想创建一个函数,它接受一个U,一个I并检查它们是否存在于该列表中的任何一个如果是,则返回true,否则返回true.例如
exists (U "John") (I "Sofa")
[(U "Mark" , I "Legion Y520", 5),
(U "Ahmed" ,I "GTX 1060", 3),
(U "Carole" , I "BMW C-Class", 5),
(U "John" , I "Maximized outlet", 4),
(U "Malik" , I "Honda Civic", 1)]
Run Code Online (Sandbox Code Playgroud)
应该返回False
这是我尝试使用的代码(extractitem和extractuser都正确提取项目的第一部分和第二部分,我已经测试过它们,问题应该是这部分)
exists :: (Eq a, Eq b) => a -> b -> [(a,b,c)] -> Bool
exists y z [] = False
exists y z (x:xs) = if ((extractuser x) == y) then if ((extractitem x) ==
z) …Run Code Online (Sandbox Code Playgroud) 我有一个包含3个元组项目的列表,我想根据第一个项目索引列表,我已经编写了一个对我来说听起来合理的代码但是我遇到了类型错误,这就是我写的内容
addIndex [] indexed = indexed
addIndex ((a1,b1,c1):xs) []
= addIndex xs [(a1,b1,c1,0)]
addIndex ((a1,b1,c1):xs) indexedWIP
= addIndexH ((a1,b1,c1):xs) indexedWIP (last indexedWIP)
addIndexH ((a1,b1,c1):xs) indexedWIP (ax,bx,cx,ix)
= if (a1 /= ax)
then (addIndex xs (indexedWIP ++ (a1,b1,c1,(ix+1))))
else (addIndex xs (indexedWIP ++ (a1,b1,c1,(ix))))
Run Code Online (Sandbox Code Playgroud)
我收到以下类型错误
ERROR file:.\lmaogetrektson.hs:109 - Type error in application
*** Expression : indexedWIP ++ (a1,b1,c1,ix + 1)
*** Term : (a1,b1,c1,ix + 1)
*** Type : (b,c,d,e)
*** Does not match : [a]
Run Code Online (Sandbox Code Playgroud)