我不知道錯誤是什麼,到目前爲止,我正在通過控制檯日誌進行測試,以在選擇文件(用於上傳)後檢查更改。Vue js錯誤:組件模板應該只包含一個根元素
當我運行$ npm run watch
,我得到以下錯誤:
"Webpack is watching the files…
95% emitting
ERROR Failed to compile with 1 errors
19:42:29error in ./resources/assets/js/components/File.vue
(Emitted value instead of an instance of Error) Vue template syntax error:
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.
@ ./resources/assets/js/components/AvatarUpload.vue 5:2-181 @ ./resources/assets/js/app.js @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss"
我File.vue是
<template>
<div class="form-group">
<label for="avatar" class="control-label">Avatar</label>
<input type="file" v-on:change="fileChange" id="avatar">
<div class="help-block">
Help block here updated 4 ...
</div>
</div>
<div class="col-md-6">
<input type="hidden" name="avatar_id">
<img class="avatar" title="Current avatar">
</div>
</template>
<script>
export default{
methods: {
fileChange(){
console.log('Test of file input change')
}
}
}
</script>
如何解決這個任何想法?什麼是實際的錯誤?