如何将渲染的 HTML 传递给 vue 属性?
How can I pass in rendered HTML to a vue property?
我正在使用 vue-material
并且我有:
<md-dialog-confirm
:md-active="true"
md-title="Make an Outboud Call"
md-confirm-text="Agree"
md-cancel-text="Disagree"
md-content="some <p>HTML</p> here"
@md-cancel="$emit('closeModal')"
@md-confirm="$emit('accept')"
>
对于 md-content
,我可以传递 HTML 但希望它通过 Vue.js 模板引擎呈现,以便我可以根据需要使用我的 {{template interpolation }}
。
有人可以帮忙吗?
您可以传递动态生成的 HTML。如果这只是一个简单的案例,您甚至可以使用 template string:
内联
<md-dialog-confirm
:md-active="true"
md-title="Make an Outboud Call"
md-confirm-text="Agree"
md-cancel-text="Disagree"
:md-content="`some text with the value <b>${yourVariable}</b> here`"
@md-cancel="$emit('closeModal')"
@md-confirm="$emit('accept')"
>
注意 md-content
前面的 :
是 v-bind
的 shorthand。
我正在使用 vue-material
并且我有:
<md-dialog-confirm
:md-active="true"
md-title="Make an Outboud Call"
md-confirm-text="Agree"
md-cancel-text="Disagree"
md-content="some <p>HTML</p> here"
@md-cancel="$emit('closeModal')"
@md-confirm="$emit('accept')"
>
对于 md-content
,我可以传递 HTML 但希望它通过 Vue.js 模板引擎呈现,以便我可以根据需要使用我的 {{template interpolation }}
。
有人可以帮忙吗?
您可以传递动态生成的 HTML。如果这只是一个简单的案例,您甚至可以使用 template string:
内联 <md-dialog-confirm
:md-active="true"
md-title="Make an Outboud Call"
md-confirm-text="Agree"
md-cancel-text="Disagree"
:md-content="`some text with the value <b>${yourVariable}</b> here`"
@md-cancel="$emit('closeModal')"
@md-confirm="$emit('accept')"
>
注意 md-content
前面的 :
是 v-bind
的 shorthand。