好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

fre.js

fre.js 介绍

介绍:

其实,free 是一部动漫名,也是我最喜欢的番没有之一,haru 是我儿子!?

安装:

yarn add fre -S

使用:

import{ observe,html,mount } from './src'

function counter() {

const data = observe({

count: 0

})

return html`

<div>

<h1>${data.count}</h1>

<button onclick=${() => {data.count++}}>+</button>

<button onclick=${() => {data.count--}}>-</button>

</div>

`

}

mount(html`<${counter} />`,document.body)

Proxy:

const data = observe({

count: 0

})

会 生成 一个 全递归的 Proxy 对象,会 自动 去observe,data 更新会 自动 触发 rerender,这个更新是准确

fre 提供 jsX-like 的 tagged template 语法,浏览器原生 支持 ,无需编译

建议根据场景选择,webpack 下 jsX 比较合适,浏览器环境肯定要 tagged template(如后端语言的模板引擎)

html`

<div>

<h1>${data.count}</h1>

<button onclick=${() => {data.count++}}>+</button>

<button onclick=${() => {data.count--}}>-</button>

</div>

`

和 jsx 一样,最终会被转换成 h 函数 ,进而 生成 vdom tree

性能 不会差,可以粗略理解为 vue 的 compile 过程,如果使用 jsx ,将直接省略这个过程

hooks API

其实这里应该叫做functionalCompoent比较合适,一种新的组件化方案。如下,fre 和 vue、react 不同,fre 的组件是无自身状态、可复用的 标记 代码 块

只有根组件拥有全局状态,但这不妨碍你进行多次 render 创造多个根组件

import{ mount,observe } from 'fre'

function counter() {

const data = observe({

count: 0

})

return html`

<div>

${html`<${count} count=${data.count} />`}

<button onclick=${() => {data.count++}}>+</button>

<button onclick=${() => {data.count--}}>-</button>

</div>

`

}

function count(props){

return html`

<h1>${props.count}</h1>

`

}

mount(html`<${counter} />`,document.body)

jsX

默 认也 对外暴露 了 h 函数 ,可以选用 jsX

import { h } from 'fre'

webpack 需配置:

{

"plugins": [

["transform-react-jsx",{ "pragma":"Fre.h" }]

]

}

网站地址 : https://fre.js.org

GitHub: https://github.com/132yse/fre

网站描述: 一个 小而美的前端 MVVM 框架

fre.js官方网站

官方网站: https://fre.js.org

如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。

查看更多关于fre.js的详细内容...

  阅读:40次

上一篇

下一篇

第1节:thinkPHP    第2节:johnny-five    第3节:Yii    第4节:WePY    第5节:ShareDB    第6节:RxJS    第7节:d3-dag    第8节:egg-react-ssr    第9节:Deep playground    第10节:Guess.js    第11节:hyperapp    第12节:Avalon.js    第13节:Inferno    第14节:HTTPie    第15节:ITPUB    第16节:dva    第17节:Quasar    第18节:graphql-yoga    第19节:Next.js    第20节:IronJS    第21节:mpvue    第22节:react    第23节:marked.js    第24节:SAPUI5    第25节:Neuro.js    第26节:enyo.js    第27节:wire.js    第28节:ui-router    第29节:vuera    第30节:tether    第31节:Mootools    第32节:graphql.js    第33节:flex.css    第34节:bacon.js    第35节:react-move    第36节:Mithril.js    第37节:Sugar.js    第38节:tabris.js    第39节:snabbdom    第40节:vuesion    第41节:anujs    第42节:Nautil    第43节:rax    第44节:Stencil.js    第45节:dio    第46节:compromise    第47节:crypto.js    第48节:imba    第49节:alt.js    第50节:svelte    第51节:react-sortable-hoc    第52节:react-snap    第53节:Fortune.js    第54节:Qatrix    第55节:KaTeX    第56节:preactjs    第57节:Lisk    第58节:Vanilla JS    第59节:es4x    第60节:styled-components    第61节:JustAuth    第62节:html2canvas    第63节:backbone    第64节:ml.js    第65节:virtual-dom    第66节:nw.js    第67节:umbrella.js    第68节:Walt    第69节:MXFlutter    第70节:FileSaver.js    第71节:Rivets.js    第72节:way.js    第73节:Flight.js    第74节:react-static    第75节:rethinkdb    第76节:Chromeless    第77节:i18next    第78节:Choo    第79节:jsMind    第80节:knockout.js    第81节:nuxt.js    第82节:Mpx    第83节:Vue    第84节:Meteor.js    第85节:Towxml    第86节:vue-resource    第87节:DefinitelyTyped    第88节:Aurelia    第89节:jsrender    第90节:Dahlia    第91节:tfjs-core    第92节:is.js    第93节:immer.js    第94节:STDLib    第95节:angular-seed    第96节:Cube.js    第97节:SproutCore    第98节:vecty.js    第99节:Maquette    第100节:Redux    第101节:Javascript Fun    第102节:moon    第103节:Ember    第104节:react-redux    第105节:falcor    第106节:normalizr    第107节:Automerge    第108节:PapaParse    第109节:LokiJS    第110节:Megalo    第111节:Selection.js    第112节:react-router    第113节:Manta    第114节:ccxt    第115节:CloudBoost    第116节:cool-admin    第117节:Vapper    第118节:ramda    第119节:Scala.js    第120节:limejs    第121节:Senna.js    第122节:fuelux    第123节:emotion    第124节:eeui    第125节:Riot.js    第126节:HooX    第127节:linaria    第128节:Keras.js    第129节:worker-dom    第130节:vite    第131节:Mermaid    第132节:Chameleon    第133节:quicklink    第134节:lovli.js    第135节:localForage    第136节:Cycle.js    第137节:Konva.js    第138节:ConvNetJS    第139节:IPFS    第140节:angular-dart    第141节:DojotoolKit    第142节:InversifyJS    第143节:cash    第144节:react-motion    第145节:hox    第146节:KISSY    第147节:mind.js    第148节:Leaflet.js    第149节:Omi    第150节:vue-router    第151节:graphql-js    第152节:vue-rx    第153节:asm-dom    第154节:weui.js    第155节:react-server    第156节:togetherjs    第157节:Duktape    第158节:Zebkit    第159节:MontageJS    第160节:Underscore.js    第161节:CanJS    第162节:Tesseract.js    第163节:sheetjs    第164节:Rocket    第165节:construct-js    第166节:rrweb    第167节:Neataptic    第168节:Flux    第169节:aframe    第170节:ThingJS    第171节:Midway    第172节:webdnn    第173节:Brain.js    第174节:UmiJs(五米)    第175节:reactxp    第176节:TensorFlow.js    第177节:Kbone    第178节:relay    第179节:H-ui    第180节:AngularJS    第181节:after.js    第182节:Dojo    第183节:jsoneditor    第184节:react-360    第185节:truffle    第186节:ale.js    第187节:pico.js    第188节:PathFinding.js    第189节:NodeList.js    第190节:interact.js    第191节:Immutable.js    第192节:cell    第193节:QuoJS    第194节:zepto.js    第195节:flutter-desktop-embedding    第196节:fre.js    第197节:Razzle    第198节:ocLazyLoad    第199节:eventproxy    第200节:vuex    第201节:angularfire2    第202节:socket.io    第203节:SkateJS    第204节:polymer    第205节:Electron    第206节:Nerv    第207节:Mind elixir    第208节:PeerJS    第209节:React Router    第210节:joi    第211节:single-spa    第212节:workbox    第213节:san    第214节:apify-js    第215节:Bootstrap    第216节:Angular    第217节:QucikUI    第218节:Expressjs    第219节:ThinkJS    第220节:Nest JS    第221节:Laravel    第222节:CodeIgniter    第223节:Zend Framework    第224节:CakePHP    第225节:Symfony    第226节:StartMVC