react-router简单使用方法

2017-03-08 13:41:36   朋也   react.js学习笔记   react.js react-router  

react-router版本 v4.x

跟着官网 https://reacttraining.com/react-router/ 上的example学习的

使用

<Router>
    <header>
        <ul>
            <li><Link to='/home'>Home</Link</li>
            <li><Link to='/about'>About</Link</li>
            <li><Link to='/login'>Login</Link</li>
            <li><Link to='/register'>Register</Link</li>
        </ul>
    </header>
    <section>
        <Route path='/home' component={Home}/>
        <Route path='/about' component={About}/>
        <Route path='/login' component={Login}/>
        <Route path='/register' component={Register}/>
    </section>
    <footer>
        balabalabala...
    </footer>
</Router>

Tampermonkey里自己写脚本,实现破晓电影下载链接显示在页面上方便复制

2017-03-06 10:54:20   朋也   脚本   javascript tampermonkey  

原因:mac上点击破晓电影下载页面不能调用迅雷,复制链接地址也不对,就写了个脚本把下载ftp地址提取出来,供复制下载用

准备

首先在chrome里装上Tampermonkey插件 下载地址

代码

点击添加新脚本

在编辑框里写上下面代码

spring-boot 使用 spring-security 博客

2017-02-21 13:33:20   朋也   spring-boot学习笔记   spring-boot spring-security  

spring-boot 使用 spring-security 博客 https://kielczewski.eu/2014/12/spring-boot-security-application/

spring-boot启动项目之后操作的实现方法

2017-02-20 10:44:50   朋也   spring-boot学习笔记   spring-boot  

web项目在启动之后有时候还会做点其它的东西(比如,导入数据脚本),下面就说说spring-boot里怎么在程序启动后加入自己要执行的东西

新建一个类:BeforeStartup.java

@Configuration
public class BeforeStartup implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private InitDB initDB;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        initDB.createUser();
    }

}

spring-boot里用freemarker做模板的国际化配置

2017-02-18 19:37:20   朋也   spring-boot学习笔记   spring-boot freemarker i18n  

网上搜索到的都是用thymeleaf模板做的国际化,没找到freemarker,然后我想到了,spring-boot 用的mvc框架不就是springmvc吗,然后就搜索了下springmvc freemarker i18n,结果还真让我找到了

配置application.yml

spring:
  messages:
    basename: i18n/messages

新建文件

在src/main/resources下新建文件夹i18n

在i18n文件夹里创建文件messages.properties、messages_en_US.properties

js模板 underscore 简单使用教程

2017-02-15 10:54:20   朋也   模板   javascript underscore template  

获取

使用

创建模板

<!DOCTYPE html>
<html>
<head>
  <title>demo</title>
</head>
<body>
  <div id="box"></div>
  <script type="text/template" id="tpl">
    hello, <%=name%>
  </script>
  <script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
  <script src="//cdn.bootcss.com/underscore.js/1.8.3/underscore-min.js"></script>
  <script type="text/javascript">
    var name = 'world';
    var render = _.template($("#tpl").html());
    $("#box").html(render({name: name}));
  </script>
</body>
</html>

2016总结

2016-12-30 13:55:42      

       14 / 16