vue项目 样式动态渲染_渲染样式

vue项目 样式动态渲染

vue项目 样式动态渲染

The question is - what will a browser do, given a page with several stylesheets, each of them probably overwriting definitions from the previous ones? Will the browser render the page using the first received css file, while downloading the other ones and after that partially re-rendering where required? The answer is: no, the browser will wait until all CSS files are downloaded, (then probably merge all definitions, just a wild guess) and will render once.

问题是-给定一个页面包含多个样式表的情况下,浏览器将如何处理,每个样式表可能会覆盖先前样式表的定义? 浏览器是否会在下载其他文件时使用接收到的第一个CSS文件来渲染页面,然后在需要时部分重新渲染? 答案是:不会,浏览器将等到所有CSS文件下载完毕(然后可能会合并所有定义,只是一个疯狂的猜测),并将呈现一次。

测试 (Test)

I did this test - one page with two stylesheets that contain pretty much the same selectors for different table styles (thanks to this gallery). Each of the CSS files is actually a PHP script and has a call to sleep(), one sleeps for 5 seconds, the other one for 10.

我进行了此测试-一页包含两个样式表,其中包含几乎相同的选择器,用于不同的表格样式(感谢此Gallery )。 每个CSS文件实际上都是一个PHP脚本,并调用了sleep() ,一个睡眠5秒钟,另一个睡眠10秒钟。

结果 (Result)

The browser sits there and waits for the both styles, rendering nothing (except for the page title, but that's not really rendering, is it?). So nothing happens for 10 seconds, then the second style is used for the final rendering. This happens in both FF and IE.

浏览器坐在那儿,等待这两种样式,什么都不呈现(页面标题除外,但这不是真正的呈现,是吗?)。 因此10秒钟没有任何React,然后将第二种样式用于最终渲染。 在FF和IE中都会发生这种情况。

杂项 (Misc)

I also tried sleeping in the actual page, and flushing the output after each row. In my home environment FF renders each row as it's received, but in my hosted environment, it waits for the whole table. IE alsways waits for the complete table.

我还尝试在实际页面中Hibernate,并在每一行之后刷新输出。 在我的家庭环境中,FF会在接收到每一行时对其进行渲染,但是在我的托管环境中,它将等待整个表。 IE始终等待完整的表。

If I put the page to too much sleep so that the php script dies before the second stylesheet is dowloaded, the browser uses whatever is at hand (css1) to render the page.

如果我让页面睡得太多,以致php脚本在下载第二个样式表之前就死了,那么浏览器将使用手头的任何东西(css1)来呈现页面。

演示/下载 (Demo/download)

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/rendering-styles/

vue项目 样式动态渲染

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue中,可以使用动态渲染style来为HTML元素绑定内联样式。通过使用绑定对象的方式,可以根据data对象中定义的属性值来动态改变样式。例如,可以使用`:style`指令来将属性值绑定到HTML元素的style属性上。 举个例子,如果在data函数中定义了属性`activeColor`和`fontSize`,可以通过`:style`指令将这些属性与HTML元素的style属性绑定起来,实现动态渲染样式。例如,可以这样写: ``` data() { return { activeColor: 'red', fontSize: 30 } } ``` 然后,在HTML模板中,可以将`:style`指令与一个JavaScript对象作为参数,对象的属性名对应CSS属性,属性值对应CSS属性值。例如: ```html <div :style="{ color: activeColor, fontSize: fontSize + 'px' }"></div> ``` 在这个例子中,`activeColor`属性值将被应用到`color`属性上,`fontSize`属性值将被应用到`fontSize`属性上,单位为像素。这样,在Vue实例的数据发生变化时,样式也会相应地动态改变。 总结起来,Vue动态渲染style的方法是使用`:style`指令,将属性值绑定到HTML元素的style属性上,通过一个JavaScript对象来定义样式属性和值的对应关系。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [【vue3】数据绑定,动态渲染class与style](https://blog.csdn.net/weixin_43361722/article/details/129824418)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值