この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:3
ページ更新者:T
更新日時:2026-05-15 05:24:41

タイトル: Emitted value instead of an instance of Error
SEOタイトル: 【Vue.jsエラー】Emitted value instead of an instance of Error

この本文には実行可能なタグ等が含まれるため、安全のためHTMLソースとして表示しています。本文データは変更していません。

<table border="1" cellpadding="1" cellspacing="1" style="width:1000px">
	<thead>
		<tr><th style="background-color:#f39c12;color:#ffffff;text-align:left">この記事の要点</th></tr>
	</thead>
	<tbody>
		<tr>
			<td style="background-color:#fef9e7">
			<ul>
				<li>Vue.js の <code>(Emitted value instead of an instance of Error)</code> エラー</li>
				<li>原因: <strong><code><template></code> 直下に複数のルート要素</strong>を置いている(Vue 2 系の制約)</li>
				<li>対処: ルート要素を<strong>1 つだけ</strong>にする(<code><div></code> 等でラップ)</li>
				<li>Vue 3 は<strong>マルチルート可</strong>なので、3 系へ移行すると解消する</li>
			</ul>
			</td>
		</tr>
	</tbody>
</table>

<p>&nbsp;</p>



<h2>エラー内容</h2>

<table border="1" cellpadding="1" cellspacing="1" style="width:1000px">
	<tbody>
		<tr>
			<td style="background-color:#000000">
			<p><span style="color:#ffffff">(Emitted value instead of an instance of Error)<br />
			&nbsp; Error compiling template:</span></p>

			<p><span style="color:#ffffff">&nbsp; &nbsp; ...</span></p>

			<p><span style="color:#ffffff">&nbsp; - Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.</span><br />
			&nbsp;</p>
			</td>
		</tr>
	</tbody>
</table>

<p>&nbsp;</p>

<h2>発生条件/原因/対処法</h2>

<p><strong><template></strong><span style="color:#e74c3c"><strong>直下</strong></span>に複数タグがあると発生するエラー。(root elementは一つでなくてはならない)</p>

<p>以下、エラー例。</p>

<table border="1" cellpadding="1" cellspacing="1" style="width:1000px">
	<tbody>
		<tr>
			<td style="background-color:#000000">
			<p><span style="color:#ffffff"><template></span></p>

			<p><span style="color:#ffffff">&nbsp;</span><span style="color:#f1c40f"> &nbsp;&nbsp;<p>aaa</p></span></p>

			<p><span style="color:#f1c40f">&nbsp; &nbsp; <p>bbb</p></span></p>

			<p><span style="color:#ffffff"></template></span></p>
			</td>
		</tr>
	</tbody>
</table>

<p><template>直下に<p>が二つあるのでエラー。</p>

<p>&nbsp;</p>

<p>以下の様に、ルートエレメントは一つでなくてはならない。</p>

<table border="1" cellpadding="1" cellspacing="1" style="width:1000px">
	<tbody>
		<tr>
			<td style="background-color:#000000">
			<p><span style="color:#ffffff"><template></span></p>

			<p><span style="color:#f1c40f">&nbsp; &nbsp; <div></span></p>

			<p><span style="color:#ffffff">&nbsp; &nbsp; &nbsp; &nbsp; <p>aaa</p></span></p>

			<p><span style="color:#ffffff">&nbsp; &nbsp; &nbsp; &nbsp; <p>bbb</p></span></p>

			<p><span style="color:#f1c40f">&nbsp; &nbsp;&nbsp;</div></span></p>

			<p><span style="color:#ffffff"></template></span></p>
			</td>
		</tr>
	</tbody>
</table>

<p>&nbsp;</p>