我正在尝试在我的React应用程序中实现深色和浅色主题。我知道主题是如何工作的,因此我可以像下面这样配置按钮:
const Button = styled.button`
/* some styles */
color: ${props => props.theme.main}
`;
Run Code Online (Sandbox Code Playgroud)
然后我将主题定义为const:
const dark = {
main: 'black',
text: 'switch to light mode'
};
const light = {
main: 'white',
text: 'switch to dark mode'
};
Run Code Online (Sandbox Code Playgroud)
当我想在某个地方使用主题时,我会像这样:
<ThemeProvider theme={dark}>
<Button>{dark.text}</Button>
</ThemeProvider>
Run Code Online (Sandbox Code Playgroud)
但是我要实现的是动态更改主题(可能在按钮的单击功能上)。我对React很陌生,所以请不要对我卑鄙。
目前,我有redux和stacknavigator,我想实现一个底部标签导航器。有了这个,我发现了关于tabnavigator的信息,我不确定如何实现这两个。这是我当前的App.js:
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStackNavigator } from 'react-navigation';
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);
import store from './store'; //Import the store
import Home from './components/home' //Import the component file
import Cart from './components/cart';
import SearchResults from './components/searchResults';
export default class App extends Component {
render() {
return (
<Provider store={store}>
<Root />
</Provider>
);
}
}
const Root = createStackNavigator(
{
Home: …Run Code Online (Sandbox Code Playgroud) javascript reactjs react-native react-redux react-navigation
我在日期范围选择器中选择了两个日期并将它们存储在一个数据库列中,但它只存储一个日期,如:0000-00-00.我不能在一列中存储两个日期,所以我想通过连字符( - )将此字符串拆分为两个变量.
这是我的日期范围功能:
<script>
$(function () {
//Initialize Select2 Elements
$('.select2').select2();
//Date range picker
$('#bilty_date_range').daterangepicker();
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是我的日期插入代码:
'bilty_date_range' => date('y-m-d',strtotime($bilty_date_range)),
Run Code Online (Sandbox Code Playgroud)
后端结果是这样的:11/07/2018 - 12/25/2018.
在我的 ionic 3 项目中,按钮图标没有居中。当我在浏览器中测试时,它可以正常工作,在 android 设备中它也可以正确显示在中心。
但只有在 ios 设备中,它才不会显示在中心。
上面的屏幕截图来自 ios 设备。因为 +,- 符号没有在中心对齐。
html代码:
<ion-col style="display: contents">
<button primary large class="inbtn" (click)="decrement()">
<ion-icon name="remove" ></ion-icon>
</button>
<h2 style="margin-left: 7px;margin-top: 0px;font-size: 2.4rem;"><b>{{currentNumber}}</b></h2>
<button primary large class="inbtn" (click)="increment()" >
<ion-icon name="add" ></ion-icon>
</button>
</ion-col>
Run Code Online (Sandbox Code Playgroud)
css:
.inbtn{
height: 30px;
width: 30px;
display: inline-block;
border-radius: 50%;
font-size: large;
font-weight: 500;
margin-left: 7px;
vertical-align: middle;
background-color: #d8d8d8 !important;
text-align: center;
-webkit-appearance: none;
}
Run Code Online (Sandbox Code Playgroud) 我可以发回一个函数引用或函数,例如对来自 Express 服务器的 api 调用的响应,并且前端框架是 Angular JS 吗?
我尝试发送响应对象,例如:{per: true, listEvnts: events}
where eventsis a function,但在我的客户端,我只得到一个带有一个键的对象:{per: true}。第二把钥匙不见了。
所需的输出将是包含两个键的响应对象,例如:{per: true, listEvents: events}。
我想检查一个电话号码是否有8位数,并且不是从零开始.我^[1-9][0-9]{7}为此目的使用了这个模式,我也想检查这8个数字是不是完全像是11111111或者77777777为了重复,我使用这个模式:(\w)\1{7,}分别检查数字与它不匹配.
现在我想将这些正则表达式模式组合在一起,但我不能.我尝试以这种方式组合这些模式:
(?=([1-9][0-9]{7}))(?:(?!(\w1{7,})))但不幸的是它不起作用.
请注意,我必须使用一个正则表达式模式,并需要将这两个模式合并为一个.
有人可以帮帮我吗?
我有3个布尔值:
船,飞机,汽车
还有3个字符串:
ReloadBoat,ReloadPlane,ReloadCar
根据这些布尔值,如果为false,我需要在字符串之间添加逗号.
string errorMessage = (Boat? "" : " " + ReloadBoat) + (Plane? "" : (errMessage) + ReloadPlane) + (Car? "" : ", " + ReloadCar);
Run Code Online (Sandbox Code Playgroud)
对于上面的问题,我得到的问题是,如果Boat和Plane都是真的,我将errorMessage作为",ReloadCar".
我希望它只是"ReloadCar".
有关如何做到这一点的任何想法?
javascript ×5
c# ×2
reactjs ×2
string ×2
angularjs ×1
codeigniter ×1
css ×1
html ×1
ionic3 ×1
jquery ×1
mysql ×1
node.js ×1
php ×1
react-native ×1
react-redux ×1
regex ×1
sockets ×1
state ×1
themes ×1
validation ×1