计划用Vue 2.0弄一个个人博客以增加校招面试的谈资。参照各种Vue 1.0的博文大致建好项目之后,Vue报错如下:[Vue warn]: Failed to mount component: template or render function not defined. (found in root instance)百度Google啃文档一大轮得知2.0后npm导入的vue不含模板编译器,不少人的解决方案都是令vue指向vue/dist/vue.js,但是文档曰single-file component已经预编译好,并不需要模板编译器。但是页面的入口并不是single-file component,那么要怎么做才能把入口做成不需要模板编译器的样子呢?看Vue.js官方的例子vue-hackernews-2.0使用服务端渲染做的,那如果不用呢?目前页面入口如下:<!DOCTYPE html><html lang="en-US"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Frontier of Marco's Self Struggling</title></head><body>
<div id="container">
<app></app>
</div>
<script src="dist/vendor.js"></script>
<script src="dist/bundle.js"></script></body></html>import Vue from 'vue'import App from './components/App.vue'var vm = new Vue({ el: '#container', components: { app: App
}
})PS. 前端小白一只,不怎么会表达自己的意思,请诸位大神多多担待
1 回答

神不在的星期二
TA贡献1963条经验 获得超6个赞
你的App是什么?难道不是整个应用的基础结构么,为什么会写在components里,应该写在render function里面。
var vm = new Vue({ el: '#container', render: h => h(App) })
添加回答
举报
0/150
提交
取消