You are using the runtime-only build of Vue where the template compiler is not available. Either pre
在升级脚手架到vue-cli3.0版本的时候出现了这个报错:
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
我在这里大概说一下出现这个报错的原因在哪里和解决办法
原因
vue有两种形式的代码 compiler(模板)模式和runtime模式(运行时),vue模块的package.json的main字段默认为runtime模式, 指向了"dist/vue.runtime.common.js"位置。
这是vue升级到2.0之后就有的特点。
而我的main.js文件中,初始化vue却是这么写的,这种形式为compiler模式的,所以就会出现上面的错误信息
// compiler
new Vue({
el: '#app',
router: router,
store: store,
template: '<App/>',
components: { App }
})
解决办法
将main.js中的代码修改如下就可以
//runtime
new Vue({
router,
store,
render: h => h(App)
}).$mount("#app")
到这里我们的问题还没完,那为什么之前是没问题的,之前vue版本也是2.x的呀?
这也是我要说的第二种解决办法
因为之前我们的webpack配置文件里有个别名配置,具体如下
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js' //内部为正则表达式 vue结尾的
}
}
也就是说,import Vue from ‘vue’ 这行代码被解析为 import Vue from ‘vue/dist/vue.esm.js’,直接指定了文件的位置,没有使用main字段默认的文件位置
所以第二种解决方法就是,在vue.config.js文件里加上webpack的如下配置即可,
configureWebpack: {
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
}
既然到了这里我想很多人也会想到第三中解决方法,那就是在引用vue时,直接写成如下即可
import Vue from 'vue/dist/vue.esm.js'
You are using the runtime-only build of Vue where the template compiler is not available. Either pre的更多相关文章
- You are using the runtime-only build of Vue where the template compiler is not available.
使用vue-cli搭建的项目,启动报错 You are using the runtime-only build of Vue where the template compiler is not a ...
- You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
异常 You are using the runtime-only build of Vue where the template compiler is not available. Either ...
- [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
转载自:https://segmentfault.com/a/1190000006435886 解决办法:添加package.config.js配置文件中,添加本文章的红色部分代码 import vu ...
- [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available
原文链接https://blog.csdn.net/xiaomajia029/article/details/88320233 问题描述: 原因分析:在项目配置的时候,默认 npm 包导出的是运行时构 ...
- Vue项目用了脚手架vue-cli3.0,会报错You are using the runtime-only build of Vue where the template compiler is not available.....
摘自: https://blog.csdn.net/wxl1555/article/details/83187647 报错信息如下图: 报错原因是:vue有两种形式的代码:一种是compiler(模版 ...
- Vue Cli 报错:You are using the runtime-only build of Vue where the template compiler is not availabl
报错原因: 这里引用的是vue.runtime.esm.js,造成的不能正常运行. vue-cli 2.x 解决方法: 在webpack.base.conf.js配置文件中多加了一段代码,将 vue/ ...
- vue.runtime.esm.js:593 [Vue warn]: Invalid prop: custom validator check failed for prop "value".报错解决
在uni中使用 picker组件,一直报错 vue.runtime.esm.js:593 [Vue warn]: Invalid prop: custom validator check failed ...
- eclipse中build path 中JDK与java compiler compliance level的问题(转)
roject facets做什么用? http://baike.baidu.com/view/6257360.htm,其实我感觉,就是让我们在创建项目时候,可以独立定义一个有一个模板供我们使用,在里面 ...
- WebStorm 使用webpack打包(build) Vue 静态资源无法访问(路径不对)问题
在WebStorm中使用webpack打包 (命令npm run build) 后生成在项目的dist目录下,在浏览器打开,静态资源js.css等无法加载.因为打包时,资源使用了绝对路径. 解决: 打 ...
随机推荐
- LeetCode - 92、反转链表 II
反转从位置 m 到 n 的链表.请使用一趟扫描完成反转. 说明: 1 ≤ m ≤ n ≤ 链表长度. 示例: 输入: 1->2->3->4->5->NULL, m ...
- Spark-2.3.2 HBase BulkLoad
在大量数据需要写入HBase时,通常有Put方式和BulkLoad两种方式. Put不做解释. BulkLoader方式的优势在于: 1.不会触发WAL预写日志,当表还没有数据时进行数据导入不会产生F ...
- Kotlin对象表达式深入解析
嵌套类与内部类巩固: 在上一次https://www.cnblogs.com/webor2006/p/11333101.html学到了Kotlin的嵌套类与内部类,回顾一下: 而对于嵌套类: 归根结底 ...
- window下关闭占用端口使用
怎么在window下关闭端口! 1:查看特定端口被占用情况 命令: netstat -ano 和 netstat -ano|findstr 端口号 netstat -ano:查看电脑所有端口被占用 ...
- Golang 内存管理
- PHPstorm不停Indexing最新解决办法
PHPstorm不停Indexing最新解决办法 1.网络上千篇一律的解决办法 File -> Invalidate Caches / Restart... -> Invalidate ...
- linux共享文件 - samba 服务器
1.Samba 服务器 客户端 yum 安装: # yum install samba samba-client -y 2.samba 配置文件配置 /etc/samba/smb.conf [glo ...
- 关于nginx反代jenkins报错 反向代理设置有误
官方文档地址: https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx 直接解决的配置文件吧. 这是使用子域名,不使用 ...
- P3719 [AHOI2017初中组]rexp——递归模拟
P3719 [AHOI2017初中组]rexp 没有什么算法的题做起来真不适应,这道题深深讽刺了我想用栈维护匹配括号个数的想法: 递归解决就行了: 时刻注意函数返回值是什么,边界条件是什么: #inc ...
- 6、httpd2.4 编译安装LAMP
www.itjc8.com 新特性: MPM支持运营DSO机制(动态共享对象),以模块形式按需加载 支持event MPM 支持异步读写 支持每模块及每个目录分别使用各自的日志级别 每请求配置 增强版 ...