当前位置: 首页 > 后端技术 > Node.js

中后台开发小木读书

时间:2023-04-03 15:41:33 Node.js

视频地址$onpush方法一个事件绑定多个方法$emitnpminstall@vue/cli-gnpminstall@vue/cli-gcnpmielement-ui-sUseelement-uiimportAppfrom'./App.vue'importElementUIfrom'element-ui';Vue.use(ElementUI);加载cnpminstallbabel-plugin-component-Dmodule.exports={presets:[['@vue/cli-plugin-babel/preset'],plugins:["component",{"libraryName":"element-ui","styleLibraryName":"theme-chalk"}]]}插件参考vue添加元素``使用规则验证数据(){constuserValidator=(rule,value,callback)=>{if(value.length>3){callback()}else{callback(newError('用户长度必须大于3'))}}return{data:{user:"sam",region:"region2"},rules:{user:[{require:true,trigger:'chang',message:'必须输入用户名'},{validator:userValidator,trigger:'change'}]}}},使用表单验证onSubmit(){console.log(this.data)this.$ref.form.validate((isValid,errors)=>{console.log(isValid,errors)})}使用:validate-status="status"控制showSuccess(){this.status='success'this.error=''},showError(){this.status='success'this.error=""},showValidating(){this.status=""this.error='validating'},sizevuex是一个vue对象响应式Dep对象vue-routerhashHistory推送本地路由守卫路由元信息{path:'/a',component:HelloWorld,meta:{title:'A'}}全局路由守卫改变标题(建议)router.beforeEach((to,from,next)=>{if(this.$route.meta.title){document.title=this.$route.meta.title}else{document.title='ch6-2'}next()})vuemixinVue.mixin({beforeCreate(){if(this.$route.meta.title){document.title=this.$route.meta.title}else{document.title='ch6-2'}}})RoutingAPI动态添加路由addRouter(){this.$router.addRoutes([{path:'/hello',component:HelloWorld}])},安装ngnixinstallhomebrew国内脚本`/bin/zsh-c"$(curl-fsSLhttps://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"``/bin/zsh-c"$(curl-fsSLhttps://raw.githubusercontent.com/Jefsky/CNHomebrew/master/CNHomebrew.sh)"`ruby-e"$(curl-fsSLhttps://raw.githubusercontent...)"brewinstallnginx修改/usr/local/etc/nginx/nginx.conf#用户mac所有者;包括/Users/mac/upload/upload.conf;upload.confserver{字符集utf-8;听8089;服务器名称http_host;根/Users/mac/上传/;自动索引;add_header缓存控制“无缓存,必须重新验证”;location/{add_headerAccess-Control-Allow-Origin*;}}执行sql脚本sourcebook.sql;阿里云免费https证书用户登录源码分析访问未知路径返回404access/xx如果不存在则从cookie中获取token令牌。检查路由是否在白名单中。访问地址。如果不在白名单中,则跳转到登录拼接地址。如果令牌存在,访问登录页面并直接重定向到主页。如果不是登录,请访问它。用户角色动态生成路由,并使用replace方式访问路由。如果有异常,清除token并访问登录并添加路由地址,生成动态路由。从路由器读取用户角色。如果是admin,直接mergeasyncrouter。如果为用户遍历路由,则有权限遍历children,过滤更新临时children。存储结果并合并过滤后的数据。侧边栏重定向登录重定向监听参数变化通过watch$route提取参数跳转重定向动态路由redirect/*path*getconst{params,q??uery}=this.$routeconst{path}=paramsthis.$router.replace({path:'/'+path,query})breadcrumbnavigationel-breadcrumbaxiosaxios.create返回请求函数发送请求请求拦截响应拦截器代码判断请求异常处理reduceoverlayPOST格式验证npmi-Sexpress-validatorJWTToken验证SHA256算法加密session保存在服务器cookie中