牛骨文教育服务平台(让学习变的简单)
博文笔记

yii2 中设置/添加 css、js、meta(keywords description) 等样式标签

创建时间:2017-07-25 投稿人: 浏览次数:877
转载请注明地址 , 尊重原创哦 . http://blog.csdn.net/banfang2013/article/details/76062086

视图中 加载 css 和 js 代码 $this->registerCss( <<< EOT_CSS
EOT_CSS );
$this->registerJs( <<< EOT_JS
EOT_JS );
加载 css 和 js 文件 $this->registerCssFile("@web/css/font-awesome.css",["depends"=>["backendassetsAppAsset"]]); //$this->registerCssFile("@web/css/index-css.css"); $this->registerJsFile("@web/js/jquery-ui.custom.js",["depends"=>["backendassetsAppAsset"]]); //$this->registerJsFile("@web/js/jquery-2.1.9.js"); //如下position是让定义CSS/JS出现的位置 //$this->registerJsFile("@web/js/jquery-ui.custom.js",["depends"=>["backendassetsAppAsset"],"position"=>$this::POS_HEAD]);
加载 meta (descriptions keywords) $this->registerMetaTag(array("name"=>"keywords","content"=>"xxx"));//第一种 $this->metaTags[]="<meta name="keywords" content="xxx"/>";//第二种

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。