错误代码
<template <img
class="avatar-img"
:src="url"
v-bind:style="{ width: size + 'px', height: size + 'px' }"
/>
<img
class="avatar-img"
:src="url"
v-bind:style="{ width: size + 'px', height: size + 'px' }"
/>
</template>
对于这个bug,我们很容易翻译为:
组件模板应该只包含一个根元素
代码改正
<template>
<div>
<img
class="avatar-img"
:src="url"
v-bind:style="{ width: size + 'px', height: size + 'px' }"
/>
<img
class="avatar-img"
:src="url"
v-bind:style="{ width: size + 'px', height: size + 'px' }"
/>
</div>
</template>