前提・実現したいこと
V英単語をテストするようなwebアプリを作ろうとしており、タイピング形式による入力と選択形式の入力とを切り替えられるようなページを作ろうとしていますが、ネストされた<router-view>が読み込まれません。
発生している問題・エラーメッセージ
VueWarn
1Error compiling template: 2 3 4 <p>以下の日本語に対する適当な英単語を答えよ.</p> 5 <router-view></router-view> 6 <p>入力</p> 7 8 9- 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. 10 11 12found in 13 14---> <Anonymous> 15 <Root>
該当のソースコード
html
1 2<body> 3 <div id="app"> 4 <nav v-cloak> 5 <router-link to="/question/typing">タイピング形式</router-link> 6 <router-link to="/question/options">オプション形式</router-link> 7 <router-link to="/result">結果画面表示</router-link> 8 </nav> 9 <router-view></router-view> 10 </div> 11 12 <script> 13 var Typing = { 14 template: ` 15 <p>//テキストボックス//</p> 16 ` 17 } 18 19 var Options = { 20 template: ` 21 <p>選択肢1</p> 22 <p>選択肢2</p> 23 <p>選択肢3</p> 24 <p>選択肢4</p> 25 ` 26 } 27 28 var Question = { 29 template: ` 30 <p>以下の日本語に対する適当な英単語を答えよ.</p> 31 <router-view></router-view> 32 <p>入力</p> 33 ` 34 } 35 36 var Result = { 37 template: ` 38 <p>結果画面</p> 39 ` 40 } 41 42 const router = new VueRouter({ 43 routes: [ 44 { 45 path: '/question/', 46 component: Question, 47 children: [ 48 {path: 'typing', 49 component: Typing 50 }, 51 {path: 'options', 52 component: Options 53 } 54 ] 55 }, 56 { 57 path: '/result', 58 component: Result 59 } 60 ] 61 }) 62 63 const app = new Vue({ router }).$mount('#app'); 64 65 </script> 66
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/07 00:53