Yii视图renderpartial不能渲染css的问题
2014-03-20 20:43
344 查看
今天在做页面的时候用到了renderpartial,结果渲染出来的页面非常“骨感”--没有任何CSS的效果。
一开始以为是自己没有把CSS的路径写对,结果仔细查了一番,路径并没有问题,同时结果页面当中也没有包含任何CSS和js脚本。怪哉怪哉!
之前用render是没有问题的,引入的css也是没有问题的,那么问题一定在renderpartial这货身上。
看源码最能解决问题。
render当中实际上也是调用了renderpartial的,唯一不同的就是render当中总是会调用processOutput,而在renderpartial当中则不然。本来指望在processOutput的源码当中看出点儿端倪,结果看了一下完全不知所云。不过问题还是可以解决的,我们看到renderpartial默认的processOutput这个参数为false,我们传一个true进去,ok问题解决。
processOutput=false(默认)时:
processOutput=true时:
一开始以为是自己没有把CSS的路径写对,结果仔细查了一番,路径并没有问题,同时结果页面当中也没有包含任何CSS和js脚本。怪哉怪哉!
之前用render是没有问题的,引入的css也是没有问题的,那么问题一定在renderpartial这货身上。
public function render($view,$data=null,$return=false) { if($this->beforeRender($view)) { $output=$this->renderPartial($view,$data,true); if(($layoutFile=$this->getLayoutFile($this->layout))!==false) $output=$this->renderFile($layoutFile,array('content'=>$output),true); $this->afterRender($view,$output); $output=$this->processOutput($output); if($return) return $output; else echo $output; } }
public function renderPartial($view,$data=null,$return=false,$processOutput=false) { if(($viewFile=$this->getViewFile($view))!==false) { $output=$this->renderFile($viewFile,$data,true); if($processOutput) $output=$this->processOutput($output); if($return) return $output; else echo $output; } else throw new CException(Yii::t('yii','{controller} cannot find the requested view "{view}".', array('{controller}'=>get_class($this), '{view}'=>$view))); }
看源码最能解决问题。
render当中实际上也是调用了renderpartial的,唯一不同的就是render当中总是会调用processOutput,而在renderpartial当中则不然。本来指望在processOutput的源码当中看出点儿端倪,结果看了一下完全不知所云。不过问题还是可以解决的,我们看到renderpartial默认的processOutput这个参数为false,我们传一个true进去,ok问题解决。
processOutput=false(默认)时:
processOutput=true时:
相关文章推荐
- fullpage插件动态添加节点,页面不能动态渲染问题解决方法
- smarty 模板不能正常加载css,js的问题
- eclipse3.4解决CSS文件中中文不能保存的问题
- IE11下,<!doctype>声明加html不能加载css的问题
- CSS - 关于li中图文混排不能垂直居中的问题
- MarkdownPad2 不能渲染的问题解决方法
- 问题:浏览器CSS/JS以怪异模式渲染
- (转)解决长串不能自动换行的问题和td中汉字自动换行 && CSS强制不换行
- jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法
- CSS中background:url(图片) 不能显示的问题
- 关于Eclipse中布局渲染时,不能显示的问题
- (转)解决长串不能自动换行的问题和td中汉字自动换行 && CSS强制不换行
- eclipse下jetty启动后不能编辑css的问题
- CSS - 解决使用浮动,父窗体不能撑高问题
- Css处理文字与图片不能水平居中对齐的问题
- jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法
- jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法
- RobotFramework测试问题三:元素不能定位问题二(css 伪元素)
- 解决SpringBoot 整合 FreeMaker,不能js,css静态资源的问题
- ie中使用css不能居中问题