问题描述
限时送ChatGPT账号..是否可以只渲染一次到一个元素中?
假设我有一个 contenteditable div,并且只想渲染第一个值,然后在模型更改时停止重新渲染.这里只会渲染variable
的初始值.
使用 v-once
{{变量}} </div>
你也可以用 包裹它:
<span v-once>{{变量}} </span>
参考:
https://vuejs/v2/guide/components.html#Cheap-Static-Components-with-v-oncehttps://vuejs/v2/api/#v-once><小时>
或者另一种解决方案是简单地克隆 variable
并且不要修改它,例如,如果您将其称为 readOnlyVariable
:
{{readOnlyVariable}} </div>
Is it possible to just render once into an element?
Suppose I have a contenteditable div, and only want to render the first value, then stop rerendering as the model changes. Here only the initial value of variable
will be rendered.
<div contenteditable="true"> {{variable}} </div>
Use v-once
<div contenteditable="true" v-once> {{variable}} </div>
You can also wrap it with a <span>
:
<div contenteditable="true">
<span v-once> {{variable}} </span>
</div>
refs:
https://vuejs/v2/guide/components.html#Cheap-Static-Components-with-v-once
https://vuejs/v2/api/#v-once
Or another solution is simply clone the variable
and just don't modify it, for example if you call it readOnlyVariable
:
<div contenteditable="true"> {{readOnlyVariable}} </div>
这篇关于VueJS 渲染一次到一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论