我有这样的组件
import React from 'react';
import styled from '../../styled-components';
const StyledInput = styled.input`
display: block;
padding: 5px 10px;
width: 50%;
border: none;
border-radius: 10px;
outline: none;
background: ${(props) => props.theme.color.background};
font-family: 'Roboto', sans-serif;
`
;
export const Input = () => {
return <StyledInput placeholder="All notes"></StyledInput>
}
Run Code Online (Sandbox Code Playgroud)
我想像这样将它们作为属性放在“索引”组件上
import styled from 'styled-components';
import { Input } from './Input';
const NoteTags:any = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
width: 20%;
height: 5%;
border-bottom: 2px solid ${(props) => props.theme.color.background}; `;
NoteTags.Input …Run Code Online (Sandbox Code Playgroud) 我有一个简单的组合框组件
我希望它在输入为空时(因此未找到匹配项时)隐藏菜单部分。
并在找到匹配时再次显示。
我无法在文档中的组合框和菜单的道具中找到任何内容。
任何帮助将不胜感激。
<v-combobox
v-model="select"
:items="states"
:search-input.sync="search"
label="Select a favorite activity or create a new one"
></v-combobox>
new Vue({
el: '#app',
data () {
return {
select: 'Any value',
search: null,
items: [],
states: [
'Alabama',
'Alaska',
'American Samoa',
'Arizona',
'Arkansas',
'California',
'Colorado',
]
}
},
watch: {
search (val) {
if(val && val !== this.select) {
this.querySelections(val)
} else {
console.log(val)
}
}
},
methods: {
querySelections (v) {
// Simulated ajax query
setTimeout(() => {
this.items …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的对象数组
const array = [
{
age: 13,
name: "Housing"
},
{
age: 23
name: "Housing"
}
]
Run Code Online (Sandbox Code Playgroud)
我想使用这个数组来创建图表,所以我需要从names和创建两个数组ages。然后我想将它作为道具传递给另一个组件
到目前为止,我在我的父组件中想出了这个
const [names, setNames] = useState([]);
useEffect(() => {
createArray();
}, []);
const createArray = () => {
if (contentLoading) {
const newNames= array.map((item) => item.name);
setNames([...names, newNames]);
}
};
Run Code Online (Sandbox Code Playgroud)
这里的问题newNames是正在创建但是当我用 hook 设置它时setNames,names它没有更新,它仍然是空的。我不确定我做错了什么。
所有的帮助将不胜感激。
我正在将我的 vue-app 部署到 gh-pages 并面临加载背景图像的问题。
这是我的项目的结构
而这里链接到我的项目上GH-页面生活。
您可以看到来自 img 标签的图像正在加载,svg 文件也在加载,但不是 svg 的背景图像没有(我所有的背景图像都在 img 文件夹中)。
我可以在控制台中看到哪些路径搞砸了——它们应该是,static/img/footer.88ceaa2.png但它们是static/css/static/img/footer.88ceaa2.png
我的组件中的背景路径应该不同还是我的配置文件中的某些内容?任何帮助都感激不尽。
我的后端有一系列错误,我想将它们发送回客户端以显示。
我正在像这样在我的行动中提出请求
export const registerUser = registeredUserData => async (dispatch) => {
const response = await axios.post('/user/register', registeredUserData);
};
Run Code Online (Sandbox Code Playgroud)
在后端我有这样的东西
if (errors && errors.length) {
res.status(400).json({ errors });
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何将错误数组返回给客户端?
我尝试换行await,try catch但errorincatch只包含一个名称,error而没有data.
有效的是,如果我摆脱status(400). 然后像成功调用一样处理它,并将数据分配给response变量。
有没有办法在保持错误状态的同时捕获客户端的数据?
reactjs ×3
chart.js ×1
express ×1
github-pages ×1
node.js ×1
react-hooks ×1
typescript ×1
vue.js ×1
vuetify.js ×1