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等无法加载.因为打包时,资源使用了绝对路径. 解决: 打 ...
随机推荐
- 阿里云ECS部署maven项目
1.配置JDK和tomcat: https://www.cnblogs.com/congcongdi/p/11227771.html 2.使用eclipse打包项目 在项目上点击右键-->run ...
- 基于yum的方式安装Cloudera Manager Server(使用Mysql 8.0版本)
基于yum的方式安装Cloudera Manager Server(使用Mysql 8.0版本) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装和配置元数据库 1>. ...
- jmeter + ant + jenkins 自动化集成环境搭建
所需工具 一.jmeter 工具下载 https://jmeter.apache.org/ 配置环境JDK等及各种插件 二.Ant安装(http://ant.apache.org/) 安装Ant是为 ...
- python3.8新特性
海象运算符(赋值运算符) #原来 def choice(): s = ' jsadlk '.strip() res = isinstance(s, int) if res: return 'int' ...
- K-means: 多次random initialization来避免bad局部最优
K-means algorithm initialize K-means算法中有一步为随机初始化cluster centroids,这步如何进行,我们将介绍一种运行比较好的方法,这种方法比其它初始化的 ...
- js判断一个数是不是正整数
js判断一个数是不是正整数 function isPositiveNum(s){//是否为正整数 var re = /^[0-9]*[1-9][0-9]*$/ ; return re.test(s) ...
- 什么是ARP协议?
ARP协议,全称“Address Resolution Protocol”,中文名是地址解析协议, 使用ARP协议可实现通过IP地址获得对应主机的物理地址(MAC地址). 在TCP/IP的网络环境下, ...
- postgresql分布式集群之citus简介(转载)
一.Citus是什么 citus是PG的一个sharding插件,可以把PG变成一个分布式数据库.目前在苏宁有大量的生产应用跑在citus+pg的环境中.大家可以看it大咖视频. citus是一款基于 ...
- BZOJ 3625:小朋友和二叉树 多项式开根+多项式求逆+生成函数
生成函数这个东西太好用了~ code: #include <bits/stdc++.h> #define ll long long #define setIO(s) freopen(s&q ...
- Mac zsh 所有命令失效
正在配置一些东西,然后zsh的所有命令不能用了. 我艹...... 然后一顿猛查,发现有个命令好使,记录一下 在命令行只想输入下面命令 PATH=/bin:/usr/bin:/usr/local/bi ...