riotjs 简单使用&&browserify 构建
http://riotjs.com/
├── app.css
├── gulpfile.js
├── index.html
├── package.json
├── README.md
├── sample.tag
├── src
│ └── app.js
└── yarn.lock
a. app.css
.demo {
font-size: 100px;
}
b. gulpfile.js
var gulp = require('gulp');
var browserify = require('browserify');
var riotify = require('riotify');
var source = require('vinyl-source-stream');
gulp.task('browserify', function(){
browserify({ entries: ['src/app.js'] })
.transform(require('browserify-css'),{global: true,autoInject:true})
.transform(riotify) // pass options if you need
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('dist/'))
});
c. index.html
<html>
<head>
<title>Hello Riot.</title>
</head>
<body>
<!-- place the custom tag anywhere inside the body -->
<example-tag></example-tag>
<todo></todo>
<!-- include the tag -->
<!-- <script type="riot/tag" src="sample.tag"></script> -->
<!-- include riot.js -->
<!-- <script src="https://cdn.jsdelivr.net/npm/riot@3.7/riot+compiler.min.js"></script> -->
<!-- mount the tag -->
<!-- <script>riot.mount('example-tag')</script> -->
<script src="dist/app.js"></script>
</body>
</html>
备注:注释的部分可以直接使用js 引用运行应用
d. package.json
{
"name": "riotjsdemo",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"riot": "^3.8.1"
},
"scripts": {
"start": "gulp browserify && live-server",
"build": "gulp browserify"
},
"devDependencies": {
"browserify": "^14.5.0",
"browserify-css": "^0.14.0",
"gulp": "^3.9.1",
"live-server": "^1.2.0",
"riotify": "^2.0.0",
"vinyl-source-stream": "^2.0.0"
}
}
e. sample.tag
<example-tag>
<p class="demo" id="findMe">Do I even Exist?</p>
<todo></todo>
<script>
var options = require("./app.css");
var test1 = document.getElementById('findMe')
console.log('test1', test1) // Fails
this.on('update', function(){
var test2 = document.getElementById('findMe')
console.log('test2', test2) // Succeeds, fires on every update
})
clickdemo=function(e){
console.log(e);
}
this.on('mount', function(){
var test3 = document.getElementById('findMe')
console.log(options);
console.log('test3', test3) // Succeeds, fires once (per mount)
})
</script>
</example-tag>
<todo>
<!-- layout -->
<h3>{ opts.title }</h3>
<ul>
<li each={ item, i in items }>{ item }</li>
</ul>
<form onsubmit={ add }>
<input ref="input">
<button>Add #{ items.length + 1 }</button>
</form>
<!-- style -->
<style>
h3 {
font-size: 14px;
}
</style>
<!-- logic -->
<script>
this.items = []
add(e) {
e.preventDefault()
var input = this.refs.input
if(input.value!=""){
this.items.push(input.value)
input.value = ''
}
console.log(input.value);
}
</script>
</todo>
f. src/app.js
var riot = require('riot')
var sample = require('../sample.tag')
riot.mount(sample)
a. 构建
yarn run build
b. 构建并运行
yarn run start
https://www.npmjs.com/package/browserify-css
https://github.com/riot/riot
https://www.npmjs.com/package/riotify
https://github.com/rongfengliang/riotjslearning.git
riotjs 简单使用&&browserify 构建的更多相关文章
- 基于Gulp + Browserify构建es6环境下的自动化前端项目
随着React.Angular2.Redux等前沿的前端框架越来越流行,使用webpack.gulp等工具构建前端自动化项目也随之变得越来越重要.鉴于目前业界普遍更流行使用webpack来构建es6( ...
- gulp:更简单的自动化构建工具
目前最流行的两种使用JavaScript开发的构建工具是Grunt和Gulp.为什么使用gulp?因为Gulp更简单.Grunt任务拥有大量的配置,会引用大量你实际上并不需要的对象属性,但是Gulp里 ...
- 简单使用Laravel-admin构建一个功能强大的后台管理
Laravel-admin可以快速构建一个功能强大的后台,方便快速开发. 以下内容记录简单使用Laravel-admin,以及遇到小错误的解决方法. Laravel-admin 依赖以下环境 需要提前 ...
- Ant简单工程的构建
1.在Ant的官方网站http://ant.apache.org/bindownload.cgi下载Ant最新版本(我下载的是apache-ant-1.8.2-bin.zip),Ant无需安装,直接解 ...
- EasyAR SDK在unity中的简单配置及构建一个简单场景。
首先打开EasyAR的官方网站http://www.easyar.cn/index.html,注册登陆之后,打开首页的开发页面. 下载sdk和Unity Samples. 创建一个unity3d工程N ...
- 基础项目构建,引入web模块,完成一个简单的RESTful API 转载来自翟永超
简介 在您第一次接触和学习Spring框架的时候,是否因为其繁杂的配置而退却了?在你第n次使用Spring框架的时候,是否觉得一堆反复粘贴的配置有一些厌烦?那么您就不妨来试试使用Spring Boot ...
- java构建简单的HTTP服务器
使用Java技术构建Web应用时, 我们通常离不开tomcat和jetty之类的servlet容器,这些Web服务器功能强大,性能强劲,深受欢迎,是运行大型Web应用的必备神器. 虽然Java的设计初 ...
- Jenkins简单入门:下载-安装-配置-构建
Jenkins简单配置流程 官网下载地址:https://jenkins.io/index.html 1.下载安装Jenkins (1)点击Download Jenkins进入下载页 (2)根据自己运 ...
- browserify使用手册
简介 这篇文档用以说明如何使用browserify来构建模块化应用 browserify是一个编译工具,通过它可以在浏览器环境下像nodejs一样使用遵循commonjs规范的模块化编程. 你可以使用 ...
随机推荐
- spring mvc: 参数方法名称解析器(用参数来解析控制器下的方法)MultiActionController/ParameterMethodNameResolver/ControllerClassNameHandlerMapping
spring mvc: 参数方法名称解析器(用参数来解析控制器下的方法)MultiActionController/ParameterMethodNameResolver/ControllerClas ...
- Docker 学习记录笔记(一)
Docker 一些简单的命令列表docker build -t friendlyhello . # Create image using this directory's Dockerfiledock ...
- 第三章 如何使用Burp Suite代理
Burp Proxy 是Burp Suite以用户驱动测试流程功能的核心,通过代理模式,可以让我们拦截.查看.修改所有在客户端和服务端之间传输的数据. 本章主要讲述以下内容: Burp Proxy基本 ...
- flask学习(四):debug模式
一. 设置debug模式 1. flask 1.0之前 在app.run()中传入一个关键字参数debug,app.run(debug=True),就设置当前项目为debug模式 2. flask 1 ...
- 解决SecureCRT下spark-shell中scala无法删除问题
转自:http://blog.csdn.net/huanbia/article/details/51318278 问题描述 当使用SecureCRT来打开Spark-shell的时候,有时会出现如下问 ...
- T4模板的基本结构
(转自:http://www.cnblogs.com/yank/archive/2012/02/14/2342287.html) T4模板的基本结构 代码块的总体分类,就是两种:文本.程序脚本. 我感 ...
- SQL语句往Oracle数据库中插入日期型数据(to_date的用法)
Oracle 在操作数据库上相比于其他的 T-sql 有微小的差别,但是在插入时间类型的数据是必须要注意他的 to_date 方法,具体的情况如下: --SQL语句往Oracle数据库中插入日期型数据 ...
- CMDB配置资源管理数据库(理解)
CMDB是运维自动化的基础,它为日志系统,发布系统,监控系统等运维系统(ELK,zabbix,open-falcon)提供接口函数, 第一种方式:Agent方法实现,agent不能直接访问数据库,因为 ...
- SpringXML方式配置bean的生存范围Scope
在一个bean的配置里面可以指定一个属性Scope,也就是bean的范围,bean的生命周期. Scope可取的值5种:singleton(默认).prototype.request.session. ...
- Mac环境下svn的使用(转)
本文目录 一.创建代码仓库,用来存储客户端所上传的代码 二.配置svn的用户权限 三.使用svn客户端功能 在Windows环境中,我们一般使用TortoiseSVN来搭建svn环境.在Mac环境下, ...