是否有一个内置的方式与jQuery"标题案例"一个字符串?所以考虑到像鲍勃史密斯这样的东西,它变成了"鲍勃史密斯"?
在我的应用程序上更改方向后,操作栏中的标题会从导航栏中选定的片段标题更改为应用程序的标题.
该抽屉式导航栏的示例应用程序保留它的标题与方向的变化,因为它的片段是主要活动的一个子类,并拥有这行代码
getActivity().setTitle(planet);
Run Code Online (Sandbox Code Playgroud)
现在我有点新手,所以我不知道如何保留标题,并实现代码,你们可以帮助吗?
万一你想看看,这里是PlanetFragment的子类
public static class PlanetFragment extends Fragment {
public static final String ARG_PLANET_NUMBER = "planet_number";
public PlanetFragment() {
// Empty constructor required for fragment subclasses
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_planet, container, false);
int i = getArguments().getInt(ARG_PLANET_NUMBER);
String planet = getResources().getStringArray(R.array.planets_array)[i];
int imageId = getResources().getIdentifier(planet.toLowerCase(Locale.getDefault()),
"drawable", getActivity().getPackageName());
((ImageView) rootView.findViewById(R.id.image)).setImageResource(imageId);
getActivity().setTitle(planet);
return rootView;
}
}
Run Code Online (Sandbox Code Playgroud) android android-fragments android-actionbar navigation-drawer
我正在尝试使用 React 设置受保护的路由(在我的情况下为主页)。它在客户端上运行良好。如果没有通过服务器验证,它会重新路由到登录页面。但从技术上讲,未经身份验证的用户仍然可以检查受保护路由上的静态内容(尽管对服务器的 api 调用当然是安全的),只需通过代码筛选或在开发工具中设置状态即可。我不喜欢这个。
TLDR 问题:如何确保未经身份验证的用户看不到受保护路由中的静态内容?
我知道身份验证必须从客户端移动到服务器。但是使用 React/React Router 执行此操作的正确方法是什么?
我的想法:
- 为未经身份验证的 React app/index.html 提供登录服务。通过身份验证后,为用户内容/页面提供另一个应用程序。
- 也许可以从服务器进行一些组件延迟加载,同时检查请求的身份验证?
我的上下文:create-react-app,express/node 后端,使用 okta auth。
谢谢你。