添加脚本包括一个顶点:组件
Adding script includes with an apex:component?
我希望通过apex:component调用我的脚本。所以在我的页面上没有 3 个包含,我想要
<c:scripts />
"脚本"组件将包含以下内容。
<apex:component >
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/jquery-1.9.1.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/jquery-ui-1.10.3.custom.min.js') }" />
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/anotherScript.js') }" />
</apex:component>
但是,如果我只想要这些脚本之一,我可以将参数传递到组件调用中吗?像下面这样...
<c:scripts
myScript = true />
然后组件...
<apex:component >
Boolean myScript = <apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/jquery-1.9.1.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/jquery-ui-1.10.3.custom.min.js') }" />
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/anotherScript.js') }" />
</apex:component>
有没有一种优雅的方法可以做到这一点?
干杯
找到答案:)
<apex:component>
<apex:attribute name="includejQuery" type="Boolean" required="false" default="false" description="True to include jQuery" />
<apex:outputPanel layout="none" rendered="{!includejQuery}">
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/jquery-1.9.1.js')}"/>
</apex:outputPanel>
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/jquery-ui-1.10.3.custom.min.js') }" />
<apex:includeScript value="{!URLFOR($Resource.jQuery, 'jQuery/js/anotherScript.js') }" />
</apex:component>
然后在我的页面中:
<apex:page>
...
<c:Scripts includejQuery="true" />
...
</apex:page>
相关文章:
- React重新渲染但未显示正确的组件
- 不能从angular2中的子组件指定父组件中的数组
- 拨打'父亲'函数形式a'儿童'ReactJS中的组件
- React组件等待所需道具进行渲染
- 如何创建带有插槽的vue js组件预加载程序
- KnockoutJS-组件-多个实例
- 如何更改reactjs中外部/独立组件的状态或属性
- 如何在react js中将值从一个组件发送到另一个组件
- React Native通过Navigator将用户输入数据传递到选项卡栏IOS中的组件
- React组件-设置页面标题
- 我的shareService在angular 2中发送值工作正常,但当我渲染我的另一个组件时,会获得默认值
- 如何在salesforce aura闪电组件中使用jQuery.val()
- 为react组件传递道具的最佳方式
- [Vue warn]:未能解析组件
- 如何控制组件'的createContent函数被激发
- react组件中的绑定方法
- 如何在react js中移动第二个组件
- 多个组件是如何实现的
- 组件生命周期问题/无法处理未定义的问题
- 添加脚本包括一个顶点:组件