如何动态获取当前URL的最后一部分没有'/'?
例如:
www.news.com/foo/bar
get - > bar
www.news.com/foo/bar/fun
get - >有趣
在当前视图中放置函数或如何实现它的位置?
我在从反应导航传递自定义浅色或深色主题时遇到问题。主题的新定义的对象项不会被覆盖,如下所示。我的目标是使用可以在每个组件中使用的自定义深色和浅色主题。但现在只显示默认值,而不显示自定义值。
应用程序.js:
import React from 'react';
import { AppearanceProvider } from 'react-native-appearance';
import Navigation from './components/Navigation.js';
const App = () => {
return (
<AppearanceProvider>
<Navigation />
</AppearanceProvider>
);
};
export default App;
Run Code Online (Sandbox Code Playgroud)
在导航组件内部,我使用 navigationContainer 根据浅色或深色主题传递主题道具。导航.js:
import React, { useState } from 'react';
import { NavigationContainer, DefaultTheme, DarkTheme } from '@react-navigation/native';
import { createStackNavigator, HeaderBackButton } from '@react-navigation/stack';
import Login from './screens/Login.js';
const Navigation = props => {
//CUSTOM THEMES
const MyTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: '#b91c22', …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 react-icons 动态加载到组件中。代码如下所示:
import React from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import * as MaterialDesign from 'react-icons/md';
const styles = {
default: {
flexDirection: 'column',
alignItems: 'center'
},
inline: {
flexDirection: 'row'
}
};
const StyledTabs = styled.button`
display: flex;
cursor: pointer;
color: ${props => props.color};
${props => styles[props.type]}
`;
const Tabs = ({ icon, type, text, color }) => {
return (
<StyledTabs icon={icon} type={type} text={text} color={color}>
<span>
<MaterialDesign.MdHome />
</span>
<span>{text}</span>
</StyledTabs>
);
}; …Run Code Online (Sandbox Code Playgroud) 我想创建一个动态网格系统,其行为应如下所示:首先,当只有 1 个项目时,它的宽度和高度应为 100%。
当第二个子项动态添加到网格时,它的高度应为 100%,两个项目的宽度应为 50%。
添加第三个项目后,前两个项目的高度应为 0f 50%,宽度为 50%,第三个项目的高度应为 50%,宽度为 100%。
第四个项目的宽度应为 50%,高度为 50%。
第五个项目再次为 100% 宽度,所有项目应具有 33,33% 高度。无论添加多少项目,网格的行为方式都应始终相同。
目前我有:
const StyledVideoContainer = styled.div`
${({ number }) => `
display: grid;
grid-template-columns: repeat(${number}, 1fr);
grid-template-rows: repeat(auto-fill, 100%);
.videoContent {
flex-grow: 1;
}
`}
`;
Run Code Online (Sandbox Code Playgroud) 在Laravel 5中创建主菜单的最佳方法是什么?以及如何仅在用户登录时显示菜单项?制作这种多语言的最佳方法是什么?
laravel ×2
laravel-5 ×2
laravel-5.1 ×2
laravel-5.2 ×2
reactjs ×2
css ×1
css-grid ×1
flexbox ×1
grid-layout ×1
react-native ×1