zl程序教程

您现在的位置是:首页 >  后端

当前栏目

magento 添加 删除css js

JSCSS 删除 添加
2023-09-14 08:59:49 时间

在addJs、addCss的代码一般在page/html_head类型的block当中,Magento首先会将所有文件存储在$_data当中,最终通过getCssJsHtml函数解析成对应的html代码输出。


Head中支持add类型的方法有addCss、addJs、addCssIe、addJsIe、addLinkRel五种。


reference name="head"         action method="addItem" type js_css /type stylesheet messagebox/blue/messagebox.css /stylesheet /action         action method="addJs" script messagebox/jmessagebox.js /script params charset="utf-8" /params /action         action method="addCss" stylesheet css/local.css /stylesheet /action         action method="addJs" script scriptaculous/controls.js /script /action         action method="addItem" type js /type name lib/ds-sleight.js /name params/ if lt IE 7 /if /action    /reference   

 通用的函数是addItem,需要指定type和name,如果有条件判断的话就放在if标签当中

 

如果需要删除某个js或者css,可以使用removeItem方法


reference name="head"    action method="removeItem" type skin_css /type name css/local.css /name /action    /reference   
js、css与高度(宽度)共享 高度共享,是高度共享和宽度共享的总称。是笔者总结的一个针对某些问题解决的思路。并不是一个新的技术点或模式 —— 至少目前来说。甚至可能你已经在项目中用过类似的。它的核心就是:降低 js 复杂计算和耗时操作在类似场景中的比重。没啥说的,通过两个业务场景描述一下即可。