vue开发的项目中遇到的警告,报错,配置项目文件等合集(长期更新)
1. Vue组件里面data()里面没有return时触发错误:Vue components Cannot read property '__ob__' of undefined

这个警告不解决会触发错误:

2. Vue项目开启局域网访问
有的项目比如移动端需要在手机上调试,这个时候需要用局域网开启在手机上查看。
解决方法:在配置文件加 --host 0.0.0.0

或者:

3.当我们运行打包脚本npm run build或者打包ios weexpack build ios有可能会遇到以下报错:ERROR in xxx.js from UglifyJs

这是因为webpack在打包vue文件时没有成功转换ES6的语法
解决方法:
解决方法很简单,加入babel-preset-es2015插件即可
1、安装依赖包
$ npm install --save-dev babel-preset-es2015
ps:babel-loader、babel-core应该是默认装好的,如果没有安装,请重新安装
2、修改【webpack.config.js】配置文件
找到 /\.js$/的rules,进行修改
{
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
presets: ['es2015']
}
}]
}
3、根目录下添加【.babelrc】文件
文件内容:
{
"presets": ["es2015"]
}
差不多效果是这样的:

下面也不知道会有了那么多东西,就这样用吧

{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}
4.运行项目时报错 Error: No PostCSS Config found in...
有时候clone下来的项目安装运行后会报这个错误,解决方法:
在项目根目录新建postcss.config.js文件,并对postcss进行配置:
module.exports = {
plugins: {
'autoprefixer': {browsers: 'last 5 version'}
}
}
在npm run dev 就好了。postcss配置在 webpack.config.js postcss.config.js是针对webpack3.0做的特殊处理。
5.Vue渲染table时调用方法修改data属性的时候报错:You may have an infinite update loop in a component render function.
<template>
<div>
<el-table :data="tableData" >
<el-table-column prop="id" label="id"></el-table-column>
<el-table-column prop="createTime" label="创建时间">
<template slot-scope="scope">
<span>{{testt('1s1')}}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default {
data() {
return {
num:,
tableData:[{id:,createTime: "2019-03-05"}]
};
},
methods: {
testt(){
this.num = this.num+
console.log(this.num+)
},
deleteRow(){
alert()
}
},
};
</script>
在循环渲染列表的时候(v-for也是如此)同时改变data属性的值就会报错:
原因:渲染组件的时候,去改变了data里面的数据,data里面的数据变化又会调用render函数,从新渲染组件,这样就造成了 死循环
vue开发的项目中遇到的警告,报错,配置项目文件等合集(长期更新)的更多相关文章
- Vue 项目中的ESlint语法报错问题
在项目中的""和;经常会报错,真的很纠结,今天看到一个解决方法,可以不用卸载删除 在项目根目录中,新建一个.prettierrc文件,来移除分号,和替换为单引号. { " ...
- vue项目中使用echarts map报错Cannot read property 'push' of undefined nanhai.js
在vue中绘制地图需要加载一个本地china.json文件,我用的是get请求的方法加载的,而不是直接import,因为我怕import请求到的部署到线上的时候会有问题.如下是get请求方法: thi ...
- ASP.NET CORE MVC 2.0 项目中引用第三方DLL报错的解决办法 - InvalidOperationException: Cannot find compilation library location for package
目前在学习ASP.NET CORE MVC中,今天看到微软在ASP.NET CORE MVC 2.0中又恢复了允许开发人员引用第三方DLL程序集的功能,感到甚是高兴!于是我急忙写了个Demo想试试,我 ...
- vue-cli创建的项目中引入第三方库报错 'caller', 'calle', and 'arguments' properties may not be...
http://blog.csdn.net/sophie_u/article/details/76223978 以在vue中引入mui第三方库为例: 虽然针对vue,有单独的vue-mui库可以使用,但 ...
- vue-cli创建的项目中引入第三方库报错'caller', 'calle', and 'arguments' properties may not be...
本文链接:https://blog.csdn.net/Sophie_U/article/details/76223978 问题: 在vue的main.js中引入mui.min.js时,报错. 如上,单 ...
- 项目中重新引用WCF报错
今天在一个项目里,重新更新WCF引用的时候,居然报错了,提示根本找不到那个WCF接口,我赶紧跑去新建了一个空项目,试着用相同的地址引用一下,发现是可以的,完全ok 既然是虚惊一场,那就得想办法把这个W ...
- vue项目中echarts使用渐变效果报错echarts is not defined
解决办法:在当前单组件中在引用一次
- 解决Maven项目中pom.xml文件报错(Failure to transfer....)的问题
打开pom.xml文件,查看错误,如果错误类型为:Failure to transfer.........之类的,则表明你的pom中依赖的jar包没有完全下载. 解决方法:找到你本地的maven仓库, ...
- vue init初始化项目后 npm run dev报错 10% building modules 1/1 modules 0 activeevents.js:182 throw er; // Unhandled 'error' event
报错信息: 10% building modules 1/1 modules 0 activeevents.js:182 throw er; // Unhandled 'error' ev ...
随机推荐
- AI:狄拉克之海上的涟漪
延陵季子2011年 8月27日 19:02 借鉴英文原文:Ripples in the Dirac Sea 当他试着用一种轻松的口吻诉说一些事情时,我会明白,其实我们都明白,在他的心里绝对不是平 ...
- Windows下VS2013 C++编译测试faster-rcnn
[原创帖!转载请注明出处:http://www.cnblogs.com/LaplaceAkuir/p/6445189.html] 本人最近研究faster-rcnn,在ubuntu成功跑通matlab ...
- Java_Reflect反射
类是对象,类是java.lang.Class类的实例对象.There is a class named Class class Foo{} public class ClassDemo{ public ...
- drf02 序列化器详解 Serializer
作用 1. 序列化,序列化器会把模型对象转换成字典,经过response以后变成json字符串2. 反序列化,把客户端发送过来的数据,经过request以后变成字典,序列化器可以把字典转成模型3. 反 ...
- OAuth网络协议
一.应用场景 为了理解OAuth的适用场合,让我举一个假设的例子. 有一个"云冲印"的网站,可以将用户储存在Google的照片,冲印出来.用户为了使用该服务,必须让"云冲 ...
- PAT_A1143#Lowest Common Ancestor
Source: PAT A1143 Lowest Common Ancestor (30 分) Description: The lowest common ancestor (LCA) of two ...
- C#第十三节课
冒泡排序 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System. ...
- 9.Spring的IOC+MyBaits+log4j+Servlet
1.创建如下mysql脚本 drop table if exists book_info; create table if not exists book_info( book_id ) primar ...
- 2.3 SVN在myeclipse中的使用
一.将svn插件文件夹复制到myeclipse的dropins目录下,并重启myeclipse 二.从SVN中检查项目到myeclipse 2.打开myeclipse,点击window的show v ...
- nodejs-n-nvm版本管理工具
第一种版本管理工具: n n是Node的一个模块,作者是TJ Holowaychuk(鼎鼎大名的Express框架作者),就像它的名字一样,它的理念就是简单: "no subshells, ...