LoginSignup
3
1

More than 1 year has passed since last update.

【Vue.js】tableタグの中でcomponentが読み込まれない

Posted at

コンポーネントが正しく読み込まれない!

<table>
  <v-hoge-thead></v-hoge-thead> 
  <tbody>
    <tr>
      <td>hogege</td>
    </tr>
  </tbody>
  ... ... 
</table>

このようなtableを作ってthead部分だけコンポーネント化していました。
そうするとコンポーネントが読み込まれているのですが、完全にレイアウトが崩れてしまいました。

調べたところ以下のドキュメントに記載がありました。

Some HTML elements, such as <ul>, <ol>, <table> and <select> have restrictions on what elements can appear inside them, and some elements such as <li>, <tr>, and <option> can only appear inside certain other elements.

(引用タグがうまくできなかった)
つまり特定のタグ、例えばul、ol、tableなどは中に決まったタグしか受け付けないようになっているようです。

なのでそういう時は読み込み方をisに変えて

<table>
  <thead is="vue:v-hoge-thead"></thead>
  <tbody>
    <tr>
      <td>hogege</td>
    </tr>
  </tbody>
  ... ... 
</table>

とするとうまく読み込まれました

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1