求教:非构建创建组件时,如何使用 ID 选择器来指向一个元素,使用其内容作为模板来源? #7705
Answered
by
zhangzhonghe
crestin
asked this question in
Help/Questions
-
如图上图:你也可以使用 ID 选择器来指向一个元素 (通常是原生的 元素),Vue 将会使用其内容作为模板来源。 求教,这句话如何理解和使用。 |
Beta Was this translation helpful? Give feedback.
Answered by
zhangzhonghe
Feb 14, 2023
Replies: 1 comment 4 replies
-
就是在 HTML 中使用 <template id="my-template-element">
<div>{{ count }}</div>
</template> 然后把 |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
crestin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
就是在 HTML 中使用
<template>
元素定义模板,如下所示:然后把
my-template-element
这个 id 传给你上面提供的图片的template
属性。前面别忘了带上#
字符。