vue 动态组件组件复用_真正的动态声明性组件
生活随笔
收集整理的這篇文章主要介紹了
vue 动态组件组件复用_真正的动态声明性组件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
vue 動態組件組件復用
在這篇簡短的文章中,我將重點介紹ADF動態聲明性組件。 我的意思是一個眾所周知的ADF標簽af:declarativeComponent 。 它可以用作將頁面設計為頁面片段和組件組成的一種非常便捷的方法。 例如,我們的頁面可以包含以下代碼片段:
PageFragment.jsff是像這樣的普通頁面片段:
<?xml version='1.0' encoding='UTF-8'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"xmlns:af="http://xmlns.oracle.com/adf/faces/rich"><af:panelGroupLayout id="pgl1"><af:outputText value="This is a page fragment. You can add your content to the following facet:"id="ot1"/><af:facetRef facetName="TheFacet"/></af:panelGroupLayout> </jsp:root>如果我們需要將一些參數傳遞給頁面片段,可以將片段定義為組件:
<?xml version='1.0' encoding='UTF-8'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"xmlns:af="http://xmlns.oracle.com/adf/faces/rich"> <af:componentDef var="attrs"><af:xmlContent><component xmlns="http://xmlns.oracle.com/adf/faces/rich/component"><facet><facet-name>TheFacet</facet-name></facet><attribute><attribute-name>Title</attribute-name></attribute></component></af:xmlContent><af:panelGroupLayout id="pgl1"><af:outputText value="This is a component #{attrs.Title}.You can add your content to the following facet:" id="ot1"/><af:facetRef facetName="TheFacet"/></af:panelGroupLayout></af:componentDef> </jsp:root>在此示例中,我們可以傳遞如以下代碼片段所示的Title屬性的值:
<af:declarativeComponent viewId="ComponentFragment.jsff"id="dc2"Title="Buttom Container">??????????????????? <f:facet name="TheFacet"><af:button text="button 2" id="b2"/></f:facet>??????????????????? </af:declarativeComponent>這項技術最酷的地方是viewId屬性不僅可以接受靜態字符串,而且還可以接受EL表達式:
<af:declarativeComponent viewId="#{TheBean.fragmentViewID}"id="dc1"><f:facet name="TheFacet"><af:button text="button 1" id="b1"/></f:facet>??????????????????? </af:declarativeComponent>public String getFragmentViewID() {return "PageFragment.jsff"; }實際上,這就是為什么這種構造稱為dynamic的原因,因此可以將此功能視為構建結構良好,靈活而動態的UI的強大工具。
而已!
翻譯自: https://www.javacodegeeks.com/2014/09/really-dynamic-declarative-components.html
vue 動態組件組件復用
總結
以上是生活随笔為你收集整理的vue 动态组件组件复用_真正的动态声明性组件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: cad视图转换快捷键(cad三视图转换三
- 下一篇: html5倒计时秒杀怎么做,vue 设