我正在使用React构建一个简单的静态视图引擎,其目标是呈现静态HTML标记并生成一个填充了组件DOM事件(onClick等)的js文件.
我正在做第一部分的方式是需要一个指定的JSX文件,例如,如下所示:
import React from 'React';
export default class Test extends React.Component {
clicked() {
alert('Clicked the header!');
}
render() {
return (
<html>
<head>
<title>{this.props.title}</title>
</head>
<body>
<h1 onClick={this.clicked}>click me!!!</h1>
</body>
</html>
);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我通过NodeJS-backend渲染JSX文件,如下所示:
let view = require('path-to-the-jsx-file');
view = view.default || view;
const ViewElement = React.createFactory(view);
let output = ReactDOMServer.renderToStaticMarkup(ViewElement(props));
Run Code Online (Sandbox Code Playgroud)
它非常适合提供静态HTML.但我想知道是否有办法在数组或其他东西中访问JSX文件中使用的所有组件,然后我可以使用它来检查绑定的事件和哪些处理程序.
那么在这个例子中,能够得到<h1>-tag的onClick-handler?这有可能以某种方式吗?
因为我们可以导入如下样式表:
<link rel="stylesheet" media="screen and (min-width: 900px)" href="widescreen.css">
<link rel="stylesheet" media="screen and (max-width: 600px)" href="smallscreen.css">
Run Code Online (Sandbox Code Playgroud)
这将通过仅加载符合media属性条件的css文件来帮助更快地加载网站.MDN
我没有运气搜索可以拆分查询的webpack配置,或者至少让我手动指定哪个css条目应该在哪个媒体上加载.
我唯一的解决方案是编写nodejs脚本并index.html在构建时注入,但在我看来这不是干净的方法.
那么有什么webpack配置这种东西?
我正在使用FAB按钮获取个人资料图片,但它已经有了一些填充.我使用以下代码创建FAB按钮.
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/student"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"/>
如何删除库自动提供的填充.我还附上了输出截图.我想删除这个天蓝色并增加src图像的大小.
我正在尝试使用firebase 9.2.1库访问FirebaseMessagingService.我已经成功创建了一个项目,然后下载了JSON文件.我终于将这个JSON文件与我的项目集成在一起.FirebaseInstanceIDService正常运行,但FirebaseMessagingService显示错误.所以我检查了android studio中的项目文件夹.然后我发现firebase-messaging 9.2.1库丢失了.我该如何解决这个问题.我已经升级了所有SDK库.请帮我解决这个问题.
我有设计一页,但它看起来不像要求.我是Xamarin的新手,我不知道如何设计像附加图像.
我的代码是
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Label Text="From" Font="20" Grid.Row="0" Grid.Column="0"></Label>
<Entry x:Name="txtFrom" HorizontalOptions="FillAndExpand" Grid.Row="0" Grid.Column="1" ></Entry>
<Label Text="To" Font="20" Grid.Row="1" Grid.Column="0"></Label>
<Entry x:Name="txtTo" Grid.Row="1" Grid.Column="1" HorizontalOptions="FillAndExpand"></Entry>
<Label Text="Subject" Font="20" Grid.Column="0" Grid.Row="2"></Label>
<Entry x:Name="txtSubject" HorizontalOptions="FillAndExpand" Grid.Column="1" Grid.Row="2"></Entry>
<Label Text="Body" Font="20" Grid.Column="0" Grid.Row="3"></Label>
<Editor x:Name="txtBody" HeightRequest="100" Grid.Row="4" Grid.ColumnSpan="2"></Editor>
<Button x:Name="btnSend" Text="Send" BackgroundColor="Orange" Grid.Row="5" Grid.ColumnSpan="2"></Button>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我已经看到很多用于获取已存储数据的示例,但没有获取任何获取存储值的示例.
我想使用 C 语言实现 RESTful Web Service。在 C 语言中进行网络和所有相关内容的最佳方式是什么?是否有任何库可以执行相同的操作?
javascript ×3
android ×2
reactjs ×2
angularjs ×1
c ×1
c# ×1
firebase ×1
grid ×1
jsx ×1
node.js ×1
protractor ×1
web-services ×1
webpack ×1