考虑 jsconfig.json 中的以下设置
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@constants/*": ["src/constants/*"]
}
}
}
Run Code Online (Sandbox Code Playgroud)
app-constants.js当我尝试通过以下方式在组件中导入文件时:
import AppConstants from "@constants/app-constants";
Run Code Online (Sandbox Code Playgroud)
我似乎收到以下错误:
Module not found: Can't resolve '@constants/app-constants'
Run Code Online (Sandbox Code Playgroud)
我的app-constants.js文件直接位于src/constants文件夹中:
知道为什么会发生这种情况吗?
编辑
我尝试使用这个:
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Run Code Online (Sandbox Code Playgroud)
并且在直接调用文件夹时有效,例如constants/app-constants.js
但当我尝试第一种方法时却没有。
如果有人能够启发我纠正我的错误,那就太好了。
考虑 C# 中的以下 JSON 字符串:
{
"BuyerRegion":"BuyerRegion [0][27]",
"SellerRegion":"SellerRegion [0][29]",
"HubRegion":"HubRegion [0][31]",
"PartNo":"TINT_MNUM [0][3]",
"BuyerCompID":"BuyerCompId [0][28]",
"SellerCompId":"SellerCompId [0][30]",
"HubCompId":"HubCompId [0][32]"
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用以下命令将字符串反序列化为 C# 中的动态对象:
object obj = new JavaScriptSerializer().Deserialize<object>(s); //where s contains the JSON string
Run Code Online (Sandbox Code Playgroud)
但是,返回的obj是键/值对的数组:
知道如何将它们反序列化为一个动态对象,我可以使用以下方式访问属性:
obj.BuyerRegion //returns "BuyerRegion [0][27]"
Run Code Online (Sandbox Code Playgroud)
JsonConvert/NewtonSoft 不是一个选择。
当我执行以下代码时:
date("d/m/y", $date)
Run Code Online (Sandbox Code Playgroud)
它给了我
15年4月6日
我怎样才能让它回归
15年4月6日
我必须做哪些修改才能获得所需的输出?请指教谢谢.
如问题中所述,假设我有一个带有多个reducer的商店(> 10个Redux状态)。
通常,在组件中,每当我们要从商店访问特定状态时,我们都会执行以下操作:
//only 3 needed states
const mapStateToProps = state => ({
prop1: state.ReducerOne.prop1,
prop2: state.ReducerOne.prop2,
prop3: state.ReducerTwo.prop1,
});
export default connect(mapStateToProps)(MyComponent)
Run Code Online (Sandbox Code Playgroud)
但是,我们只会抛出使组件起作用所需的状态。
mapStateToProps即使不需要使用它们,也可以将商店中的每个单一状态都放入每个组件中吗?性能会受到任何影响吗?
我有一个日期/时间选择器,我希望他们根据其布局做出反应.
考虑横向模式:
这是我想要的完美位置.但是,如果我把它转到肖像模式,我会得到类似下面的内容:部分时间丢失了.
我目前的代码是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/DarkGrey" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<DatePicker
android:id="@+id/custom_datePicker"
android:calendarViewShown="false"
android:layout_height="170dp"
android:layout_width="wrap_content"
android:layout_marginTop="-10dp"
android:layout_marginBottom="-10dp" />
<TimePicker
android:id="@+id/custom_timePicker"
android:layout_height="170dp"
android:layout_width="wrap_content"
android:layout_marginTop="-10dp"
android:layout_marginBottom="-10dp" />
</LinearLayout>
<Button
android:id="@+id/btnDone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Done"
style="@style/Widget.AppCompat.Button.Colored"
android:theme="@style/General.Button">
</Button>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
将内部LinearLayout的方向更改为Vertical将实现我想要的纵向模式,但它在横向模式下会混乱,反之亦然.
有什么替代方法呢?是否可以在屏幕模式转换时以编程方式更改布局的方向?