小编QoP*_*QoP的帖子

自定义字体与Ionic2

在我的Ionic2项目中,我将我的字体(ttf格式)放在www/build/fonts文件夹中.但是当我构建应用程序时,字体消失了.

我能怎么做 ?

ionic2

18
推荐指数
3
解决办法
2万
查看次数

SpringBoot - UTF-8在messages.properties中不起作用

有什么问题?

我无法在UTF-8中显示我在messages.properties中收到的消息.

一个例子

<h1 id="logo">Electrónico</h1>
Run Code Online (Sandbox Code Playgroud)

这工作没问题但是当我尝试使用这样的消息源时

<h1 id="logo" th:text="#{titulo.electronico}">Electrónico</h1>
Run Code Online (Sandbox Code Playgroud)

我得到"Electr nico"而不是Electrónico

这是我的配置

application.properties

spring.messages.encoding=UTF-8
server.tomcat.uri-encoding=UTF-8
spring.http.encoding.charset=UTF-8
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
Run Code Online (Sandbox Code Playgroud)

的pom.xml

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <start-class>demo.Demo</start-class>
    <java.version>1.7</java.version>
</properties>
Run Code Online (Sandbox Code Playgroud)

演示课

@SpringBootApplication
public class Demo {

    public static void main(String[] args) {
        SpringApplication.run(Demo.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

ServletInitializer.class

@Configuration
public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Demo.class);
    }

    @Bean
    public ServletRegistrationBean h2servletRegistration() {
        ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
        registration.addUrlMappings("/console/*");
        return registration;
    }

    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    CharacterEncodingFilter characterEncodingFilter() {
      CharacterEncodingFilter filter = …
Run Code Online (Sandbox Code Playgroud)

spring utf-8 thymeleaf

16
推荐指数
4
解决办法
2万
查看次数

HTML SVG - 是否可以将<svg>导入Adobe Illustrator进行修改?

正如标题所说,我如何在Adobe Illustrator中修改svg?

例如,我得到了这个

<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="595.28px" height="841.89px" viewBox="0 0 595.28 841.89" enable-background="new 0 0 595.28 841.89" xml:space="preserve">
<text transform="matrix(1 0 0 1 225 321)" font-family="'MyriadPro-Regular'" font-size="12">This a TEST!</text>
<path fill="none" d="M177,246c0,92.859,77.824,168,174,168"/>
<path fill="none" d="M357,246c0,161.398-105.555,292-236,292"/>
<path fill="none" d="M288,414c0,113.311-23.252,205-51.987,205"/>
<rect x="93" y="383" fill="none" width="364" height="147"/>
<g>
    <rect x="167" y="272" fill="none" width="216" height="244.5"/>
</g>
<rect x="476" y="428" fill="none" width="216" height="244.5"/>
<rect x="121" y="230" fill="none" width="403" height="231"/>
<rect x="179" y="158" fill="none" width="362" height="454.25"/>
<rect x="73" y="230" fill="none" width="294" height="184"/> …
Run Code Online (Sandbox Code Playgroud)

html svg

12
推荐指数
2
解决办法
3万
查看次数

如何使用@hostbinding为Angular 2中的host元素提供类

我想给我的组件的host元素一个类,所以直到现在我使用这样的host属性:

@Component({
  selector: 'left-bar',
  host: { 'class': 'left-bar' },
  templateUrl: 'app/left-bar/left-bar.component.html',
  styleUrls: ['app/left-bar/left-bar.component.css']
})
export class LeftBarComponent implements OnInit {

  ngOnInit() {
  }

}
Run Code Online (Sandbox Code Playgroud)

现在虽然我收到了TypeScript的警告,但这是一个不好的做法.

[tslint] In the "@Component" class decorator of the class "LeftBarComponent" you are using the "host" property, this is considered bad practice. Use "@HostBindings", "@HostListeners" property decorator instead.
Run Code Online (Sandbox Code Playgroud)

如何以更正确的方式向主元素添加类并摆脱此警告?

谢谢!

更新:基于以下答案:我得到了类,但是在添加类之后样式不会影响父主机元素.我的风格很简单:

.left-bar {
  position: fixed;
  width: 120px;
  left: 0;
  top: 0;
  bottom: 0;
  background: #323232; }
Run Code Online (Sandbox Code Playgroud)

css typescript angular

10
推荐指数
1
解决办法
1万
查看次数

Angular2在获取资源时监视302重定向

我需要从我公司持有的另一个域中提取一些资源.我想用GET请求提取安全的HTML内容.

当用户退出应用程序时,所请求的内容将返回302到登录页面.

我试图嗅探302的标题并没有返回到目前为止我所希望的.我的Observable返回的响应是200(登录页面).

这是我的示例应用程序.

export class MenuComponent implements OnInit {

    private _resourceUrl = "http://localhost:3001/resources/menu";

    constructor(private _http: Http){
    }

    menu: string;

    ngOnInit(): void {
        this.getMenu()
            .subscribe(
                response => {
                    console.log(`Response status: ${response.status}`);

                    this.menu = response.text();
                },
                error => console.log(<any>error));
    }

    getMenu(): Observable<Response>{        
        return this._http.get(this._resourceUrl)
            .map((response: Response) => response)
            .catch(this.handleError);
    }

    private handleError(error: Response){
        console.log(error);
        return Observable.throw(error.json().error || 'Server Error');
    }
}
Run Code Online (Sandbox Code Playgroud)

我是否走在正确的轨道上?

rxjs angular2-http angular

9
推荐指数
1
解决办法
1万
查看次数

neo4j bolt驱动程序比http端点慢

到目前为止,我们正在使用http端点进行读取查询,并计划转移到java bolt驱动程序.但在初始测试中,观察到螺栓驱动器比http端点慢.以下是我们正在使用的java驱动程序代码.

在应用程序上下文级别创建的驱动程序实例:驱动程序neo4jReadDriver = GraphDatabase.driver("bolt://xyz.com",AuthTokens.basic("neo4j","neo4j"),Config.build().withMaxSessions(20).toConfig ());

执行查询的应用程序代码:

    Session session = neo4jReadDriver .session();

    StatementResult result = session.run( "MATCH(p:GOE) return count(p) as cnt");


    while ( result.hasNext() )
    {
        Record record = result.next();
        System.out.println("Total number of GOEs:"+ record.get( "cnt").asInt());

    }
    result.consume();
    session.close();
    driver.close();
Run Code Online (Sandbox Code Playgroud)

此查询始终比http端点花费的时间加倍.大多数时间在driver.getSession().我在这做错了吗?如何使用bolt java驱动程序和并发用户执行读取查询来获得高吞吐量?

neo4j neo4j-bolt

6
推荐指数
1
解决办法
1370
查看次数

VelocityJS(速度 - 动画)+ WebPack - 我该如何使用它?

我已经开始使用Webpack了,我已经从NPM安装了VelocityJS(速度动画).

我这样导入它

import Velocity from 'velocity-animate';
Run Code Online (Sandbox Code Playgroud)

但我真的不知道如何使用它.

例如......我怎么写这个?

$('.secondary-content').velocity({translateX: '0%'});
Run Code Online (Sandbox Code Playgroud)

我试过这个但是没用.

Velocity.$('.secondary-content').velocity({translateX: '0%'})

javascript webpack velocity.js

5
推荐指数
1
解决办法
3257
查看次数

对于Angular2项目,我如何连接从typescript生成的所有JavaScript文件并将它们添加到我的index.html文件中

对于Angular2项目,我如何连接从typescript生成的所有JavaScript文件并将它们添加到我的index.html文件中.

我正在使用Angular2,typescript和gulp.

目前我没有连接它从typescript文件生成的javascript文件.

我无法尝试这样做并将它们添加到我的index.html文件中.

另外,一旦我完成了这个,我需要缓存清理,以便让浏览器保持请求javascript文件.

这是我的index.html文件:

<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns#" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>My App</title>
    <base href="/"></base>
    <meta content="IE=edge, chrome=1" http-equiv="X-UA-Compatible"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=0.5, user-scalable=yes"/>

    <!-- Css libs -->
    <link rel="stylesheet" type="text/css" href="/css/styles.css" /> 

    <!-- inject:css -->    
       <!-- <link rel="stylesheet" href="/css/styles.81dd14d5.css">     -->
    <!-- endinject -->

    <!-- Js libs -->    
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>    
    <script type="text/javascript" src="/safariPolyFix.js"></script>    
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system.src.js"></script>   

    <script>
        System.config({
            transpiler: 'typescript',
            defaultJSExtensions: true,  
            typescriptOptions: {
                emitDecoratorMetadata: true,
            },          
            packages: {
                'angular2-google-maps': {
                  defaultExtension: 'js' …
Run Code Online (Sandbox Code Playgroud)

javascript typescript gulp angular

5
推荐指数
1
解决办法
3012
查看次数

使用ngUpgrade测试Angular应用程序失败,显示"未知提供程序:ng2.InjectorProvider < - ng2.Injector"

我正在尝试使用ngUpgrade从ng1移动到ng2,并在升级期间保持我的Karma/Jasmine测试通过,但是我遇到了一个我无法弄清楚的错误.

我已将Service(Data)升级为ng2 @Injectable,并将upgradeAdapter.downgradeNg2Provider其注入我的ng1应用程序.它在生产代码中工作正常.

但是当我尝试在我的测试中注入它时,我得到了这个错误:

Error: [$injector:unpr] Unknown provider: ng2.InjectorProvider <- ng2.Injector <- Data
Run Code Online (Sandbox Code Playgroud)

任何人都有一个在ngUpgrade中间单元测试代码的工作示例?我的堆栈是基于Webpack的.我试过跟踪并转换systemjs指南,但没有任何运气.

karma.conf.js:

module.exports = function (config) {
  config.set({
    // base path used to resolve all patterns
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files/patterns to load in the browser
    files: [{ pattern: 'spec.bundle.js', watched: false }],

    // files to exclude
    exclude: [],

    plugins: [
      require('karma-phantomjs-launcher'),
      require('karma-jasmine'),
      require('karma-webpack')
    ], …
Run Code Online (Sandbox Code Playgroud)

ng-upgrade angular

5
推荐指数
1
解决办法
1478
查看次数

Redux reducer用于按名称从列表中删除对象

我见过的关于从列表中删除项目的大多数示例都使用列表中项目的索引,例如:

case REMOVE:
  return [
    ...list.slice(0, action.index)
    ...list.slice(action.index + 1)
  ]
Run Code Online (Sandbox Code Playgroud)

但是,如果我想调度一个无法访问列表中项目索引但只能访问名称的操作,我该如何过滤一组对象并仅删除一个具有n名称的对象?

ecmascript-6 reactjs redux react-redux

5
推荐指数
2
解决办法
6370
查看次数