我目前正在尝试使用React和Material-UI。
我有一个组件,其中包括另一个组件。在render()I´m 内部,遍历呈现<FormDialog />组件的伪数组。
<ul>
{tableContent.map((item, i) =>
<li key={i}>{item.x}
<FormDialog/>
</li>
)}
</ul>
Run Code Online (Sandbox Code Playgroud)
当使用REACT-TOOLS检查DOM时,我当然可以看到Dialog组件是其中的3倍。
我目前正在问自己这是否是错误的做法,在我将组件渲染20到50次左右时,在现实世界中会导致严重的性能问题。
如果这是一个问题
我真正喜欢的是Dialog组件开箱即用,不需要打开或关闭任何其他组件“操作”。因此,当这个示例不好的做法会给我带来很大的性能问题时,我看不到保持Dialog Component强大的自我一致性功能的选项。
这是对话框组件,只是从Material-UI演示中复制的:
import React from 'react';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
export default class FormDialog extends React.Component {
state = {
open: false,
};
handleClickOpen = () => {
this.setState({ open: true });
};
handleClose …Run Code Online (Sandbox Code Playgroud) 我目前正在研究 Spring Boot 并致力于一个小型示例项目。但是由于将 Bootstrap 与 Spring-Boot-Security 包一起使用,我面临着一个非常令人困惑的问题。当我使用以下代码时,页面不会与 Bootstrap 一起显示。
我的 SecurityConfiguration.java 看起来像这样
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.authorizeRequests().antMatchers("/","/products","/product/show/*","/console/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").permitAll()
.and()
.logout().permitAll();
httpSecurity.csrf().disable();
httpSecurity.headers().frameOptions().disable();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("admin").password("{noop}admin").roles("ADMIN")
.and().withUser("user").password("{noop}user").roles("USER");
}
}
Run Code Online (Sandbox Code Playgroud)
我认为有点令人困惑的是我得到了 301/ 未修改,但是当我尝试这样做以防止我缓存问题时,我完全重新打开了浏览器并使用了一个私人窗口。
当我禁用几乎所有安全功能时,我的页面会使用 Bootstrap 正确呈现。
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception …Run Code Online (Sandbox Code Playgroud) java spring-mvc spring-security twitter-bootstrap-3 spring-boot
我正在使用 Google Maps Static API 请求图像为 PNG。目前我正在将此图像保存到文件系统,然后我将使用 PHPMailer 将此图像发送给我的客户。发送完所有邮件后,图像将从文件系统中删除。
我现在的目的是省去将图像保存到文件系统的步骤,只需使用内存中的图像对象并通过邮件发送。但似乎 PHPMailer 必须在文件系统上有一个图像才能使用它。
我目前在做什么:
从静态 API 请求图像
$URL = "http://maps.googleapis.com/maps/api/staticmap?center=Albany,+NY&zoom=13&scale=false&size=600x300&maptype=roadmap&format=png&visual_refresh=true";
$image = file_get_contents($URL);
Run Code Online (Sandbox Code Playgroud)
将图像保存到文件系统并将其发送到我的邮件功能
$fp = fopen('../../img/staticMap/staticMap.png', 'w+');
fputs($fp, $image);
fclose($fp);
unset($image);
$file = "../../img/staticMap/staticMap.png";
$notifications->notifySingleUser($file); //Call my Mail Function
Run Code Online (Sandbox Code Playgroud)
在邮件中嵌入图像
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->IsHTML(true);
$mail->AddEmbeddedImage($file, "staticMap");
$mail->Body = "<img width="600" height="300" src="cid:staticMap">";
Run Code Online (Sandbox Code Playgroud)
我还做了一些研究PHPMailer 附件,在没有物理文件的情况下进行,但在这里他们只是在谈论如何使用 AddAttachment,但我想要 AddEmbeddedImage。我也试过,邮件发送没有任何错误,但没有图像。
这甚至可能吗?如果是,我该如何存档?
image ×1
java ×1
javascript ×1
material-ui ×1
php ×1
phpmailer ×1
reactjs ×1
spring-boot ×1
spring-mvc ×1