该设置可以用在生产环境中,避免用户看到报错信息之类的,影响用户体验

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		
		<div id="app">
			<div>{{hll}}</div>
			<button @click="division()" type="button">1/0</button>
		<!-- </div> -->
		
		<script type="text/javascript">
			
			//上面div不是闭合标签但是浏览器依然没有报错
			Vue.config.silent = true;
			new Vue({
				el: "#app",
				data: {
					hll: "贫穷的本质",
				},
				methods: {
					division (){
						let arr = [1,2,3]
						for (var i = 0; i < 6; i++) {
							console.log(arr[i]);
						}
						return 1/0;
					}
				}
			})
		</script>
	</body>
</html>

Logo

前往低代码交流专区

更多推荐