Vue.js v2.0.0-alpha.5 發布,一個構建數據驅動的 web 界面的庫
Vue.js(讀音 /vju?/, 類似于 view)是一個構建數據驅動的 web 界面的庫。Vue.js 的目標是通過盡可能簡單的 API 實現響應的數據綁定和組合的視圖組件。
Vue.js 自身不是一個全能框架——它只聚焦于視圖層。因此它非常容易學習,非常容易與其它庫或已有項目整合。另一方面,在與相關工具和支持庫一起使用時,Vue.js 也能完美地驅動復雜的單頁應用。
如果你喜歡下面這些,那你一定會喜歡 Vue.js:
- 可擴展的數據綁定機制
- 原生對象即模型
- 簡潔明了的 API
- 組件化 UI 構建
- 多個輕量庫搭配使用
10 秒鐘看懂 Vue.js
更新日志
新功能
-
The
render
function now receives the component instance's$createElement
method as its only argument. This avoids having to aliasingthis.$createElement
to something less verbose:Vue.extend({ render (h) { return h('div', null, 'hello!') } })
-
Functional components:
A component can be defined as a stateless functional component with
functional: true
.- A functional component has no instance and is simply a function that receives props and children vnodes via arguments, and also return vnode(s).
- Unlike stateful components, functional components are not restricted by the "single root node" rule and can return an Array of multiple vnodes.
- A functional component's render function receives the following arguments:
createElement
: the parent component's$createElement
method.props
: an object containing propschildren
: children inside the component's tag as vnodes
Example usage:
Vue.component('wrap-with-tag', { functional: true, props: ['tag'], render (h, props, children) { return h(props.tag, null, children) } })
When used in template:
<wrap-with-tag tag="div">hello</wrap-with-tag>
Will render:
<div>hello</div>
</li> </ul>重大更改
-
v-ref
is now no longer a directive: it is now a special attribute similar tokey
andtransition
:<!-- before --> <comp v-ref:foo></comp>
<!-- after --> <comp ref="foo"></comp></pre>
Dynamic ref bindings are now also supported:
<comp :ref="dynamicRef"></comp>
</li> -
The
<render>
tag is removed in favor of stateless functional components. -
It is now prohibited to replace a component instance's root
$data
. This prevents some edge cases in the reactivity system and makes the component state more predictable (especially with type-checking systems).
</ul>
下載
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!