Skip to content

Commit d15a846

Browse files
committed
优化页面滚动事件监听
1 parent 4a1e45a commit d15a846

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/views/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<div class="subTitle">JOIN BYTEDANCE</div>
2121
</h1>
2222
<div class="search">
23-
<input-search @search="searchJobs" size="small" placeholder="输入城市或职位进行搜索"></input-search>
23+
<input-search @search="searchJobs" placeholder="输入城市或职位进行搜索"></input-search>
2424
</div>
2525
<div class="bottom-tips">
2626
<span class="arrow-down" @click="scrollDown">

src/views/Jobs.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ let searchBarClientHeight = 0;
6767
export default {
6868
name: "job",
6969
data() {
70-
const { keyword = "", job_category_id = "" } = this.$route.params;
7170
return {
72-
searchKeyword: keyword,
71+
searchKeyword: "",
7372
currentPage: 1,
74-
job_category_id_list: job_category_id ? [job_category_id] : [],
73+
job_category_id_list: [],
7574
jobCategories: [],
7675
jobCities: [],
7776
location_code_list: [],
@@ -83,6 +82,12 @@ export default {
8382
};
8483
},
8584
85+
activated() {
86+
this.searchKeyword = this.$route.params.keyword || "";
87+
if (this.$route.params.job_category_id) {
88+
this.job_category_id_list = [this.$route.params.job_category_id];
89+
}
90+
},
8691
created() {
8792
const jobConfigRequest = this.request
8893
.get("/job-filters")
@@ -104,19 +109,21 @@ export default {
104109
positionY = this.$refs.searchBar.offsetTop;
105110
searchBarClientHeight = this.$refs.searchBar.clientHeight;
106111
});
112+
},
113+
activated() {
107114
const onPageScroll = () => {
115+
108116
const top = this.$refs.searchBar.getBoundingClientRect().top;
109117
110118
this.searchBarFixedTop =
111119
window.scrollY > positionY - searchBarClientHeight / 2;
112120
};
113121
window.addEventListener("scroll", onPageScroll);
114122
115-
this.$once("hook:destroyed", () => {
123+
this.$on("hook:deactivated", () => {
116124
window.removeEventListener("scroll", onPageScroll);
117125
});
118126
},
119-
120127
computed: {
121128
queryFilter() {
122129
return {
@@ -135,7 +142,7 @@ export default {
135142
},
136143
watch: {
137144
queryFilter: function(newVal, oldVal) {
138-
newVal.offset !== oldVal.offset && window.scrollTo(0, positionY);
145+
this.searchBarFixedTop && window.scrollTo(0, positionY);
139146
this.fetchList();
140147
}
141148
},

src/views/ResumeEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ export default {
11091109
.concat(this.$refs.basicForm.validate())
11101110
);
11111111
} catch (error) {
1112-
throw error;
1112+
this.$message.error('表单验证未通过')
11131113
return;
11141114
}
11151115

0 commit comments

Comments
 (0)