现有两个组件 欢迎页和主页
主页的生命周期钩子created
created(){
console.log(this.$store.state);
//返回的是Observer类型,不能得到具体的,只能在他之后的钩子调用
},
beforeMount(){
this.userInfo=this.$store.state.userinfo;
console.log(this.$store.state.userinfo);//可获取
}
我在一进入小程序的时候首页的created钩子会被执行,但是其他钩子不会。
所以一个mpvue项目在运行时会执行所有页面的created,beforeCreate钩子。
在项目中使用sass 直接安装sass-loader,node-sass就好了