简单的 vue 应用程序不显示任何内容 [英] Simple vue app doesn't show anything
本文介绍了简单的 vue 应用程序不显示任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
完整代码:https://github.com/kenpeter/test_vue_template
git clone https://github.com/kenpeter/test_vue_template
安装:yarn install
运行:yarn dev
访问 localhost:8080
什么也看不见
解决方案
因为你没有在你的根组件中渲染任何东西.
在你的 index.html
中,渲染 app
组件:
<app></app>
有几种方法可以做到这一点.如果你不想动你的index.html
,你也可以修改main.js
.下面的所有代码都应该可以工作:
new Vue({el: '#app',渲染:h =>h(应用程序),成分: {应用程序}})
或
new Vue({el: '#app',模板:'<App/>',成分: {应用程序}})
Full code: https://github.com/kenpeter/test_vue_template
git clone https://github.com/kenpeter/test_vue_template
install: yarn install
run: yarn dev
visit localhost:8080
and see nothing
解决方案
Because you didn't render anything in your root component.
In your index.html
, render the app
component:
<div id="app">
<app></app>
</div>
There are several ways to do this. If you don't want to touch your index.html
, you can also modify the main.js
. All of the code below should work:
new Vue({
el: '#app',
render: h => h(App),
components: {
App
}
})
or
new Vue({
el: '#app',
template: '<App/>',
components: {
App
}
})
这篇关于简单的 vue 应用程序不显示任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文