1. Vue.config.productionTip = false
开发模式:npm run dev 开发过程中使用
生产模式:npm run build 打包之后给后端放在服务端
Vue.config.productionTip = false,阻止显示生产模式的消息。全局配置,关闭产品控制台提示
如果没有这行代码,或者设置为true,控制台会多出下面一段代码:
You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
意思是运行的vue是开发模式。为生产部署时,请确保启用生产模式。
2. render: h => h(App) $mount
初始化项目后,main.js中有一段代码:
new Vue({
render: h => h(App),
}).$mount('#app')
作用是创建一个vue对象,然后挂载到指定的页面节点。创建当前项目运行的根实例组件。
render函数可还原为:
render:(function(createElement){
return createElement(App);
})
缩写为ES6语法:
render (h){
return h(App);
}
进一步转为箭头