使用的Vue(^ 2.0.0-rc.6) + Browserify,入口點是index.js:Vue JS 2.0沒有渲染任何東西?
import Vue from 'vue'
import App from './containers/App.vue'
new Vue({ // eslint-disable-line no-new
el: '#root',
render: (h) => h(App)
})
App.vue:
<template>
<div id="root">
<hello></hello>
</div>
</template>
<script>
import Hello from '../components/Hello.vue'
export default {
components: {
Hello
}
}
</script>
<style>
body {
font-family: Helvetica, sans-serif;
}
</style>
Hello.vue:
<template>
<div class="hello">
<h1>\{{ msg }}</h1>
</div>
</template>
<script>
export default {
data() {
return {
msg: 'Hello Vue!'
}
}
}
</script>
空白屏幕,我錯過了什麼?
編輯:
入門HTML只是<div id="root"></div>
,在控制檯日誌中沒有錯誤,我敢肯定,因爲該文件出現在控制檯console.log('test')
Hello.vue被加載。
編輯2:
發現錯誤:
[Vue warn]: You are using the runtime-only build of Vue where the template option is not available. Either pre-compile the templates into render functions, or use the compiler-included build. (found in anonymous component - use the "name" option for better debugging messages.)
這是否意味着我必須使用的WebPack解決方案?不能使用標準的HTML?
SOLUTION: 導入Vue公司從 'VUE /距離/ vue.js'
只是可以肯定。當使用webpack時,建議更改webpack配置,而不是'vue/dist/vue.js'' import Vue https://github.com/vuejs/vue/wiki/Vue-2.0-RC-Starter-Resources #standalone-vs-runtime-builds –
請使用解決方案做出回答,並接受它) –
如果你已經回答了你自己的問題,你可以發佈下面的答案並接受它,或者刪除你的問題。我們不在標題 – j08691