在我正在开发的应用程序中,对于桌面和移动,它完全需要两个不同的视图。使用CSS不可能,因为内容完全不同。
我做了什么?
我已经在Routing file使用代码检查过它是否是台式机/手机const isMobile = window.innerWidth < 768;
并在路径组件中: component: isMobile ? MobileComponent : DesktopComponent
这在开发环境中运行良好。但是,尽管生产构建失败了ng serve --prod(显然是Angular 5)
问题:
完全没有错误,根据对isMobile/错,它应该加载MobileComponent / DesktopComponent。但是即使isMobile为true / false,也不会加载
始终在桌面和移动设备中加载MobileComponent。而isMobile价值是越来越计算正确,true对Mobile和false对Desktop
我认为原因是路由在发送给客户端之前已经得到了编译。
解决方法已尝试但不起作用:
在计算isMobile并给出该变量(组件)而不是路由文件中的三元运算时,使用了if..else条件
任何方式:
有什么方法可以用来实现相同的功能?
提前致谢
我试图改变鼠标悬停的风格.
我的代码是:
<Button Name="register" Content="Register" Margin="15,410,20,0" Padding="6" FontSize="18" VerticalAlignment="Top" Background="#FF0090D6" BorderBrush="#FF0090D6" Foreground="White">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Run Code Online (Sandbox Code Playgroud)
但背景是默认的.但是当我改变属性BorderThickness然后它起作用.
我究竟做错了什么?