}, created() { //this.bg(); let type = this.$route.query.type ? this.$route.query.type : ''; this.init(type); this.baseUrl = this.$config.baseUrl; this.ruleForm.fabushijian = this.getCurDateTime() }, methods: { getMakeZero(s) { return s < 10 ? '0' + s : s; }, // 下载 download(file){ window.open(`${file}`) }, // 初始化 init(type) { this.type = type; if(type=='cross'){ var obj = JSON.parse(localStorage.getItem('crossObj')); for (var o in obj){ if(o=='shipinmingcheng'){ this.ruleForm.shipinmingcheng = obj[o]; this.ro.shipinmingcheng = true; continue; } if(o=='shipinfengmian'){ this.ruleForm.shipinfengmian = obj[o].split(",")[0]; this.ro.shipinfengmian = true; continue; } if(o=='shipin'){ this.ruleForm.shipin = obj[o]; this.ro.shipin = true; continue; } if(o=='yonghuming'){ this.ruleForm.yonghuming = obj[o]; this.ro.yonghuming = true; continue; } if(o=='xingming'){ this.ruleForm.xingming = obj[o]; this.ro.xingming = true; continue; } if(o=='fabushijian'){ this.ruleForm.fabushijian = obj[o]; this.ro.fabushijian = true; continue; } if(o=='thumbsupnum'){ this.ruleForm.thumbsupnum = obj[o]; this.ro.thumbsupnum = true; continue; } if(o=='crazilynum'){ this.ruleForm.crazilynum = obj[o]; this.ro.crazilynum = true; continue; } if(o=='clicknum'){ this.ruleForm.clicknum = obj[o]; this.ro.clicknum = true; continue; } } }
时间: 2023-07-15 07:13:51 浏览: 89
Vue中this.$router.push参数获取方法
这段代码是一个 Vue.js 组件的 created 钩子函数,用于初始化组件。在这个函数中,首先根据路由参数获取 type 值(如果没有则默认为空字符串),然后调用 init 方法进行初始化。在 init 方法中,根据 type 值判断是否为 cross 类型,然后从本地存储中读取 crossObj 对象,并解析其中的各个属性值,将其赋值给组件中对应的数据属性中。这个组件可能是用于发布视频信息的表单组件,其中包含了视频名称、封面、视频、用户信息等多个属性。
阅读全文